Re: [xsl] ID Generation for XML Element

Subject: Re: [xsl] ID Generation for XML Element
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 29 Oct 2010 13:58:57 +0200
Ramkumar.V wrote:

Below are the inputs. I need to generate sequential ID for all the sect element including any nesting element sec/sec/sec for sec2 sec 3 sec4

   <xsl:template match="sect">
       <xsl:variable name="pos"><xsl:number/></xsl:variable>

Use <xsl:variable name="pos"><xsl:number level="any"/></xsl:variable>

And instead of the xsl:choose and ancestor check you could simply write different templates e.g.
<xsl:template match="body/sect">
<xsl:variable name="pos"><xsl:number level="any"/></xsl:variable>
<sect1 id="sect{$pos}">
<xsl:apply-templates/>
</sec1>
</xsl:template>
<xsl:template match="body/sect/sect">
<xsl:variable name="pos"><xsl:number level="any"/></xsl:variable>
<sect2 id="sect{$pos}">
<xsl:apply-templates/>
</sec2>
</xsl:template>
and so on for the other levels.


--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread