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]
Other format: [Raw text]

Re: problem with xsl:number


Hi Bryan,

> <xsl:number> would give  you the position of the element in the source
> tree. Try giving a node value to the count attribute..
> <xsl:number count = "node you wana count"/>
>  thanks I'll try that.
> althought I thought as a default it counted the current node?

It does - more importantly, by default it counts at a level of
'single', so it gives you the position of the current node amongst
other nodes of that type (and name) in the same parent. So if you
have:

  <ol>
    <li>option 1</li>
    <li>option 2</li>
    ...
  </ol>

and then match li elements and number them:

<xsl:template match="li">
  <xsl:number format="1. " />
  <xsl:value-of select="." />
</xsl:template>

then you get the correct numbering of 1 through to however many items
there are in the list.

You seem to want to number images across the *entire document* rather
than within the parent element. If so, you should use the level
attributeof xsl:number with a value of 'any', to say that you want to
count the image amongst other images in the document rather than just
its parent:

<xsl:template match="image">
  <xsl:number level="any" />
  ...
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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]