Subject: RE: [xsl] How to use arrays in XSLT? From: <Jarno.Elovirta@xxxxxxxxx> Date: Wed, 29 Sep 2004 09:55:03 +0300 |
Hi, > Can I use arrays in the XSLT program? XPath doesn't have an array data type, but there are ways to get where you want. > I want to hold hundreds of (name,value) pairs in an array,, > may be in 2 arrays > 1st array ==> name > 2nd array ===> value > > so that I can index on the name to get the value of that name... > > Is it possible in XSLT??? If you have a static array, then create something in the lines of <x:map> <entry key="..." value="..."/> ... </x:map> and stick that inside xsl:stylesheet. Then define an xsl:key as <xsl:key name="lookup" match="entry/@value" use="../@key"/> and then do a look-up with <xsl:variable name="key" select="get-key-value"/> <xsl:for-each select="document('')"> <xsl:value-of select=key('lookup', $key)"/> </xsl:for-each> There are other ways doing it, e.g. if you need to use a dynamic map or if you use XSLT 2.0, but in that case you should describe your needs in more detail. Hope this helps. Cheers, Jarno - Nick Sentience: March 2003 Mix
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to use arrays in XSLT?, Ganesh Prasad .M | Thread | [xsl] regex grouping precedence., Pawson, David |
[xsl] How to use arrays in XSLT?, Ganesh Prasad .M | Date | [xsl] regex grouping precedence., Pawson, David |
Month |