[xsl] following-sibling in a sorted result tree?

Subject: [xsl] following-sibling in a sorted result tree?
From: "Peter Heald" <healdp@xxxxxxxxxxx>
Date: Wed, 27 Apr 2005 15:44:21 -0700
Hi,

I have an xslt2 transform that outputs multiple html documents, as well as index files and hhc/hhk htmlHelp files.

Part of this is a sorted xsl:for-each loop that references the previous and next siblings (used to add next and previous page buttons in the html).

I have found that the sibling instructions reference the unsorted result tree, not the sorted tree which is the current context. The results match the order of the original XML, not the sorted loop, therefore the previous and next buttons are not in sync with the index and content pages, which are also sorted. So I'm guessing that following-sibling, for example, is not using the sorted result tree at all. Is there a way around this? Do I somehow need to create a parallel result tree?

Any thoughts would be much appreciated. Below is a little pseudo-code demonstrating the problem.

<xsl:for-each select="ITEM">
<xsl:sort select="@NAME"/>
<xsl:result-document href="./{$something}.html" format="myhtml">
.....
<xsl:value-of select="following-sibling::*[1]/@NAME"/> <!--next sorted ITEM ? -->
....
</xsl:result-document>
</xsl:for-each>


Why would the value-of line above result the next sibling according to the original XML file order and not the sorted order?

Thanks! Pete

Current Thread