xsl-list
[Top] [All Lists]

[xsl] XSLT transformation using counters

2011-04-26 10:28:29

 
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">&#13;&#10;&lt;ParaStyle:div&gt;</xsl:text>
<xsl:apply-templates/>
</xsl:template>
 
<xsl:template match="div">
<xsl:text 
disable-output-escaping="yes">&#13;&#10;&lt;ParaStyle:div&gt;</xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="heading">
<xsl:text 
disable-output-escaping="yes">&#13;&#10;&lt;ParaStyle:hd1&gt;</xsl:text>
<xsl:apply-templates/>
</xsl:template>
 
                                          
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--