This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Numbering quandry



Perfect! Thanks for the useful explanation, as well!

Stephen Blake
Veritect
s t e p h e n . b l a k e @ v e r i t e c t . c o m

-----Original Message-----
From: Wendell Piez [mailto:wapiez@mulberrytech.com]
Sent: Thursday, April 12, 2001 12:40 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] Numbering quandry


Stephen:

It looks like you have the numbering of each node working okay, it's the 
numbering of the parent that's not working.

That's because when you say
         <xsl:text>Section </xsl:text>
         <xsl:value-of select="@title"/>
         <xsl:text> (</xsl:text>
         <xsl:number level="multiple" count="section" format="1.1.0"/>
         <xsl:text>, parent </xsl:text>
         <xsl:number level="multiple" count="section/section"
format="1.1.0"/>
         <xsl:text>)</xsl:text>

that second <xsl:number ...> is still taking the current node matched by 
the template as its context node. The 'count' attribute identifies what 
nodes should be counted, but it doesn't change the fact that the number 
inserted is 'based on the position of the current node in the source tree' 
[XSLT 7.7].

So to count the parent, you have to change the current node to be the 
parent of the node your template has matched, for that invocation of the 
<xsl:number/> instruction. You can do this by wrapping it in a for-each 
like so:

         <xsl:text>Section </xsl:text>
         <xsl:value-of select="@title"/>
         <xsl:text> (</xsl:text>
         <xsl:number level="multiple" count="section" format="1.1.0"/>
         <xsl:text>, parent </xsl:text>
        <xsl:for-each select="..">
          <xsl:number level="multiple" count="section/section"
format="1.1.0"/>
        </xsl:for-each>
         <xsl:text>)</xsl:text>

which will count the correct nodes ... then you'll have to adjust the 
'count' attribute to count the correct nodes (I'll leave you to figure that 
out).

Good luck,
Wendell

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]