Re: [xsl] Does XSL have arrays?

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 name="daysFromStartOfYear" select="sum(msxsl:node-

This assumes you have numeric variables $month and $day. It uses the
'node-set' extension function, but this is available in most XSLT

Richard Light.

Richard Light
SGML/XML and Museum Information Consultancy

 XSL-List info and archive:

Current Thread