sorting grouping data

Here should go questions about transforming XML with XSLT and FOP.
Posts: 2
Joined: Fri Dec 01, 2006 2:06 pm

sorting grouping data

Post by Misha » Fri Dec 01, 2006 2:34 pm

im havin XML:
<?xml version="1.0" encoding="iso-8859-1" ?>
<item id="i1" catalog="s1" subcatalog="u1">561</item>
<item id="i10" catalog="s3" subcatalog="u4">15</item>
<item id="i22" catalog="s2" subcatalog="u2">1234</item> etc
<catalog id="s1">catalog 1</catalog>
<catalog id="s2">catalog 2</catalog>
<catalog id="s3">catalog 3</catalog>

<subcatalog id="u1">Subcatalog 1</subcatalog>
<subcatalogid="u2">Subcatalog 2</subcatalog> etc

by meas of 2-level grouping (using keys) shoul look as follows:
catalog 1

Subcatalog 1

ID Value

id1 value1
catalog 2

Subcatalog 1

ID Value

id1 value1...


my xsl:
<xsl:variable name="Sort1" select="@catalog"/>
<xsl:variable name="Sort2" select="@subcatalog"/>

<xsl:key name="Sector" match="item" use="@catalog"/>
<xsl:key name="Subsector" match="item" use="concat(@catalog, ' ',@subcatalog)"/>

<xsl:template match="data" >

<xsl:variable name="Sort11" select="key('Sector',substring-after($Sort1,'s'))"/>
<xsl:variable name="Sort22" select="key('Subsector',concat(substring-after($Sort1,'s'),' ',substring-after($Sort2,'u')))"/>

<xsl:for-each select="item[count(. | key('Sector', @catalog)[1]) = 1]">

<xsl:sort select="*[name()=$Sort11]" order="ascending" data-type="number"/>

<xsl:value-of select="//sector[@id=current()/@catalog]"/>
<xsl:variable name="Items" select="key('Sector', @catalog)" />

<xsl:for-each select="$Items[generate-id() =generate-id(key('Subsector',concat(@catalog,' ',@subcatalog))[1])]">

<xsl:sort select="*[name()=$Sort22]" order="ascending" data-type="number"/>

<xsl:value-of select="//subcatalog[@id=current()/@subcatalog]" />
<xsl:for-each select="key('Subcatalog',concat(@catalog,' ',@subcatalog))">
<xsl:value-of select="@id"/>
<xsl:text> </xsl:text>
<xsl:value-of select="."/>


It groups but doesnt sort, i believe the problem is in syntax in sorting. Any ideas?
Tnx in advance :)