[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Displaying a combination of text and child nodes
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="{@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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|