Karen,
The xml is (I have just pulled out a few lines):
<?xml version="1.0" encoding="UTF-8"?>
<doxygen>
<compounddef>
<codelisting>
<programlisting>
      <codeline lineno="1">
...
The xsl I am using is:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Code listing for a nominated function.  -->
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <xsl:template match="/">
...
                                      <xsl:for-each 
select="doxygen/compounddef/programlisting/codeline">
                                              <tr>
                                                      <td>
                                                              
For one thing, maybe this is just an
artifact of how you excerpted your XML, but the way you show it,
the path to <codeline> is
  /doxygen/compounddef/codelisting/programlisting/codeline
whereas your <xsl:foreach> says
   select="doxygen/compounddef/programlisting/codeline"
In other words, "codelisting/" is missing.
<xsl:for-each select="highlight">
                                                              
      <span class="<xsl:value-of select="@class"/>>
This isn't what you asked about, but probably instead of the above
you want to use an Attribute Value Template:
     <span class="{(_at_)class}">
Much more pleasant, isn't it?  :-)
Doesn't seem to matter what I do here, I can get the whole 
text, ignoring sp elements, or I can get the first sp element, -->
                                                  <!-- or I 
can get the first text element only, depending on what I do  -->
                                                  <!-- I have 
tried xsl:for-each loops, I've tried matching templates, but 
I still can't seem to get it to work.  -->
Did you try <xsl:for-each select="*|text()"> ?
* will select child element nodes, and text() will select child text
nodes. Unioned together with "|", you get both.
Or maybe you want <xsl:for-each select="sp|text()">.
Another alternative would be to use apply-templates:
 <xsl:apply-templates select="*|text()" />
Then you could create a template for processing <sp>s,
another for text nodes, another for <ref>s, etc.
(If you were trying <xsl:value-of ...> without a <xsl:for-each>,
that would be why you only got the first element or text node;
<xsl:value-of select="nodeset"/> converts only the *first* node
in nodeset into a string.)
HTH,
Lars
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list