[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Number of node in list from stylesheet

Subject: Number of node in list from stylesheet
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Tue, 23 May 2000 12:24:41 +0100
assigned number to node xsl
Hi,

In answering Cheun Ngen CHONG's question about comparing dates, I ran into
a couple of problems that have left me puzzled (other one is in separate
email).

Within the stylesheet, I needed to convert a month's name into a month
number, so January = 01, May = 05 and so on.  So I defined the months in
order within the stylesheet itself:

<foo:months>
  <foo:month name="January" abbr="Jan" />
  <foo:month name="February" abbr="Feb" />
  ...
</foo:months>

Let's say that the month name is in a variable called $monthName.  How can
I assign a variable $monthNumber to the equivalent (two-digit) number?

I have tried xsl:number, but the count attribute cannot include the
document() function.

I have tried position(), but I don't know how, within a variable, to set
the context node list equal to the foo:month nodes and the context node
equal to the foo:month node with the desired name.  For example:

  <xsl:variable name="monthNumber">
    <xsl:for-each select="document('')//foo:month[@name = $monthName]">
      <xsl:value-of select="format-number(position(), '00')" />
    </xsl:for-each>
  </xsl:variable>

always sets $monthNumber = 1.

What am I missing?

Thanks for your help,

Jeni



Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email
jeni.tennison@xxxxxxxxxxxxxxxx



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.