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 12:51:57 +0200
Ramkumar.V wrote:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0"> <xsl:output method="xml" encoding="us-ascii" indent="no" omit-xml-declaration="no" include-content-type="no" />
<xsl:template match="root"><article><xsl:apply-templates/></article></xsl:template> <xsl:template match="sect"><section id="sec{position() div 2}"><xsl:apply-templates/></section></xsl:template>
<xsl:template match="sect/title"><title><xsl:apply-templates/></title></xsl:template>
<xsl:template match="para"><p><xsl:apply-templates/></p></xsl:template> </xsl:stylesheet>

<?xml version="1.0" encoding="us-ascii"?><article>
<section id="sec1">
<title>Section Head1</title>
<p>Paragraph text</p>
</section>
<p>Element para or some other any element and any no.of element may come here</p>
<section id="sec2">

Try it with xsl:number <xsl:template match="sect"> <xsl:variable name="pos"><xsl:number/></xsl:variable> <section id="sec{$pos}"> <xsl:apply-templates/> </section> </xsl:template>


--


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

Current Thread