|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: QUESTION about xsl:number
At 00/05/04 13:21 -0700, Kelvin Zheng wrote:
My question is how to number its child nodes as: Correct ... because you haven't told it what needs to be counted ... as a result it is only counting the current element. The example below (not accommodating white space) illustrates how using a union in the pattern gives the processor a list of things to count. I hope this helps. .......... Ken
<section type="title" shownumber="no">
XML sample
</section>
<section type="index" shownumber="yes">
Definition
<definition>
XML
</definition>
<definition>
XSL
</definition>
</section>
<section type="index" shownumber="yes">
Implementation
</section></document> T:\ftemp>type test2.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/><xsl:template match="/"> <!--root rule--> <xsl:apply-templates select="//section"/> </xsl:template> <xsl:template match="section">
<xsl:if test="@shownumber='yes'">
<xsl:number count="section[@shownumber='yes']"/>
</xsl:if>
<xsl:apply-templates/>
</xsl:template><xsl:template match="definition">
<xsl:number count="section[@shownumber='yes']
|definition"
level="multiple" format="1."/>
<xsl:value-of select="."/>
</xsl:template></xsl:stylesheet> T:\ftemp>xt test2.xml test2.xsl XML sample
1
Definition
1.1.
XML 1.2.
XSL 2
Implementation
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








