[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Number of node in list from stylesheet
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
|
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
|