XSLT takes the input tree and converts it to the result tree, your path expressions always work on the input tree, so any brothers and sisters you are looking for are moved to the input tree. With XSLT 2.0 (or with XSLT 1.0 and an extension function such as exsl: node -set http://www.exslt.org/exsl/index.html ) you can create variables with temporary trees then you can navigate, for example,
<xsl:variable name="rtf1"> <xsl:for-each select="hist:Step"> <xsl:sort data-type="text" select="hist:End" order="ascending"/> <xsl:copy-of select="."/> </xsl:for-each> </xsl:variable> <xsl:apply-templates select="exsl:node-set($rtf1)/hist:Step"/>
then it will process the temporary element of the Step node that has been sorted.
With XSLT 2.0, you don't need an exsl: node -set call.
source share