I want to be able to sort elements based on an attribute in my XML. Unfortunately I cannot seem to get it to work, here is my code so far.
Currently no errors are produced but the sort doesn’t seem to ever be applied descending.
<xsl:variable name="sortOrder">
<xsl:choose>
<xsl:when test="Lanes/@flip = 1">descending</xsl:when>
<xsl:otherwise>ascending</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:for-each select="Entry">
<xsl:sort data-type="number" select="@id" order="{$sortOrder}"/>
</xsl:for-each>
XML:
<Lanes flip="1">
<Entry id="1" value="0"/>
<Entry id="2" value="0"/>
</Lanes>
Test case for your sample:
XSL
Output for me: