|
Subject: Re: [xsl] Does XSL have arrays? From: Richard Light <richard@xxxxxxxxxxxxxxxxx> Date: Thu, 4 Jan 2001 08:22:36 +0000 |
In message <200101040407.f0447xI10025@xxxxxxxx>, Mike Brown
<mike@xxxxxxxx> writes
>I would probably attempt it anyway, though. For example,
>if you just want the number of days in a given month (1-12),
>it would be something like this...
>
><xsl:variable name="month" select="6"/>
><xsl:variable name="days" select="number(substring('312831303130313130313031',$m
>onth * 2 - 1,2))"/>
How about using a chunk of XML as your 'array'? Something like this:
<xsl:variable name="daysInMonth">
<month n="1" days="31"/>
<month n="2" days="28"/>
<month n="3" days="31"/>
<month n="4" days="30"/>
<month n="5" days="31"/>
<month n="6" days="30"/>
<month n="7" days="31"/>
<month n="8" days="31"/>
<month n="9" days="30"/>
<month n="10" days="31"/>
<month n="11" days="30"/>
<month n="12" days="31"/>
</xsl:variable>
<xsl:variable name="daysFromStartOfYear" select="sum(msxsl:node-
set($daysInMonth)/month[@n<$month]/@days)+$day"/>
This assumes you have numeric variables $month and $day. It uses the
'node-set' extension function, but this is available in most XSLT
processors.
Richard Light.
Richard Light
SGML/XML and Museum Information Consultancy
richard@xxxxxxxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Does XSL have arrays?, Mike Brown | Thread | Re: [xsl] Does XSL have arrays?, Mike Brown |
| Re: [xsl] Name of current node's pa, Mike Brown | Date | Re: [xsl] position in a conditional, Jeni Tennison |
| Month |