getting next node in sorted node list
Posted: Sat Oct 23, 2010 7:30 am
Hello,
Given a silly XML document:
I have an xslt style sheet that iterates over each letter node in sorted order and prints out the letter:
That works fine, it just prints out a k z.
However, as the foreach is processing the letter k, I would also like it to print out the value of the next letter.
That's where I'm stuck. The following-sibling axis prints out document order, not node list order. I can use position() to get the index of the k node (in this case 2), but I have no idea how/where to use that to do (position() +1).
Can anyone help me work out how to get the next node in node list order, not document list order?
Many many thanks
H.
Given a silly XML document:
Code: Select all
<alpha>
<letter>k</letter>
<letter>z</letter>
<letter>a</letter>
</alpha>
Code: Select all
<xsl:for-each select="/alpha/letter">
<xsl:sort />
<xsl:value-of select="text()" />
</xsl:for-each>
However, as the foreach is processing the letter k, I would also like it to print out the value of the next letter.
That's where I'm stuck. The following-sibling axis prints out document order, not node list order. I can use position() to get the index of the k node (in this case 2), but I have no idea how/where to use that to do (position() +1).
Can anyone help me work out how to get the next node in node list order, not document list order?
Many many thanks
H.