Subject: XSLT transformation using counters
From: Bubba O'Reily <killswi7ch1@xxxxxxxx>
Date: Tue, 26 Apr 2011 11:28:16 -0400
|
Hi,
I can't seem to get a handle on how to set a counter or variable then then
output the results. I have a XML file (snippet) tagged like so:
Input:
<body>
<lev>
<hd>heading</hd>
<lev>
<hd>heading</hd>
<lev>
<hd>heading</hd>
<lev>
<hd>heading</hd>
</lev>
</lev>
</lev>
</lev>
</body>
How can I set a counter and insert the results in the <HD?> tag below?
Output:
<body>
<lev>
<hd1>heading</hd>
<lev>
<hd2>heading</hd>
<lev>
<hd3>heading</hd>
<lev>
<hd4>heading</hd>
</lev>
</lev>
</lev>
</lev>
</body>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="div">
<xsl:text
disable-output-escaping="yes"> <ParaStyle:div></xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="div">
<xsl:text
disable-output-escaping="yes"> <ParaStyle:div></xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="heading">
<xsl:text
disable-output-escaping="yes"> <ParaStyle:hd1></xsl:text>
<xsl:apply-templates/>
</xsl:template>
|