Project

Profile

Help

Bug #6472 » ForEachGroupSortOrderIssue.xslt

Adrian Bird, 2024-07-07 10:25

 
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="data">
<root>
<item name="bbb" />
<item name="ddd" />
<item name="bbb" />
<item name="aaa" />
<item name="ccc" />
</root>
</xsl:variable>

<xsl:template name="xsl:initial-template">
<root>
<xsl:call-template name="fegTemplate">
<xsl:with-param name="ordering">descending</xsl:with-param>
</xsl:call-template>

<xsl:call-template name="fegTemplate">
<xsl:with-param name="ordering">ascending</xsl:with-param>
</xsl:call-template>
</root>
</xsl:template>

<xsl:template name="fegTemplate">
<xsl:param name="ordering" select="string('ascending')" />
<h>for-each-group <xsl:value-of select="$ordering" /></h>
<xsl:for-each-group select="$data/root/item" group-by="@name">
<xsl:sort order="{$ordering}" select="current-grouping-key()" />
<t><xsl:value-of select="current-grouping-key()" /></t>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
    (1-1/1)