Hi,
I need a help in doing 2 level grouping (& sequencing - mentioned later) on my XML - Thanks in advance for any
input : I want to do it in XSLT 1.0 (not 2.0)
I - 2 level grouping
input XML:
Expected output XML:
<?xml version="1.0" encoding="utf-8"?> 100 01 02 08 200 02 300 03Description:
As you may notice from the above, I want to group all the level2’s that have the same Level1 keys. (see the
one with L1key value 100).
How do I do that? My XSLT is given below - but it only displays one Level2 (not all of them)
XSLT:
<xsl:stylesheet version=“1.0” xmlns:xsl=“XSLT Namespace”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:xs=“XML Schema”
exclude-result-prefixes=“xs”>
<xsl:output method=“xml” encoding=“UTF-8” indent=“yes”/>
<xsl:key name=“L1key” match=“Level1” use=“L1key”/>
<xsl:template match=“/File”>
<xsl:attribute
name=“xsi:noNamespaceSchemaLocation”>C:/BTPOC2~1/XSLTTE~1/out_xsd.xsd</xsl:attribute>
<xsl:for-each select="Level1[generate-id()=generate-id(key('L1key',L1key))]">
<L1>
<L1key>
<xsl:for-each select="L1key">
<xsl:value-of select="."/>
</xsl:for-each>
</L1key>
<xsl:for-each select="Level2">
<L2>
<xsl:for-each select="L2key">
<L2key>
<xsl:value-of select="."/>
</L2key>
</xsl:for-each>
</L2>
</xsl:for-each>
</L1>
</xsl:for-each>
</File>
</xsl:template>
</xsl:stylesheet>
II - sequencing:
In the above, for example, if I expand the output XML - level 2 as
01, i.e. to introduce the sequence # to identify each L2key value uniquely ,
how do I do that?
Thanks,
Ken