[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: processing alternating sibling nodes
Steve,
The trouble is here: At 03:38 PM 12/31/2002, you wrote: > <xsl:for-each select="descendant::question"> > <xsl:value-of select="text"/> > <xsl:value-of select="reference"/> > </xsl:for-each> Since you have a single <question> descendant of the context node, the context shifts to that; the stylesheet then puts out values of the sets of "text" element children (select="text") and reference children (select="reference"). However, the 'value-of' instruction you are using explicitly pulls out a string value; since the string value of a set of nodes is defined (in XPath 1.0) as the string value of the first node in the set (in document order), that's what you're getting: your first <text> followed by the first <reference>. I'd suggest junking the for-each instruction (it's doing nothing but changing the context node) and instead saying in its place, <xsl:apply-templates select="question/text"/> which tells the processor to process (by applying templates to) *all* the <text> children of the <question> children of the context node. Then write another template for the text, as in <xsl:template match="text"> <xsl:value-of select="."/> <xsl:value-of select="following-sibling::reference[1]"/> </xsl:template> This time, for each text node its own value is reported (a string value of a node set with one member: no problem), and then the value of its next following reference element is reported. The logic here assumes you have a straight text/reference/text/reference sequence of simple pairs (no helpful wrappers). You will need to qualify it further if your data is not so regular. (Of course this could also be done within your for-each if you really wanted.) I hope that helps, Wendell
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
|