Re: [xsl] Problem with generating references.

Subject: Re: [xsl] Problem with generating references.
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Tue, 05 Jul 2005 14:48:41 +0200
Tempore 14:57:07, die 07/05/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Lakshmi narayana <lchintala@xxxxxxxxxxxx>:

for each element so that I can identify each element uniquely).

1. Divide the elements into groups.
2. While dividing, create the references to the elements in the current
group which are going to be placed in another group.

This stylesheet generates the ouput from your sample. It will need some adaption though, to work in a real situation.

<xsl:stylesheet xmlns:xsl=""; version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="element" match="*" use="substring(local-name(),1,1)"/>

<xsl:template match="/">
<xsl:for-each select="//*[generate-id()=generate-id(key('element',substring(local-name(),1,1)))]">
<xsl:element name="{substring(local-name(),1,1)}-group">
<xsl:for-each select="key('element',substring(local-name(),1,1))">
<xsl:for-each select="*">
<reference><xsl:attribute name="id"><xsl:number count="*" level="any"/></xsl:attribute></reference>


regards, -- Joris Gillis ( Spread the wiki (

Current Thread