June 1999
Intermediate to advanced
540 pages
21h 39m
English
<xsl:counter>
<xsl:counter name="
string
"/>
Provides a named counter that appears in the result tree. The
counter is initialized using the <xsl:counter-reset/> element
and incremented using the <xsl:counter-increment/> element.
Consider the following XML document:
<book> <chapter>Introduction</chapter> <chapter>Learning to Fly</chapter> <chapter>Simple Aerobatics</chapter> </book>
The following XSL numbers and lists each of the chapters in the result tree:
<xsl:template match="book" > <xsl:counter-reset name="chaps"/> <xsl:apply-templates> </xsl:template> <xsl:template match="book/chapter"> <xsl:text>Chapter </xsl:text> <xsl:counter name="chaps"/> <xsl:counter-increment name="chaps"/> <xsl:text>:</xsl:text> <xsl:apply-templates> </xsl:template>
Read now
Unlock full access