Subject:node-set - Arrays in XSLT? Author:k j Date:24 Mar 2006 06:32 AM
Hi all,
I want to be able to parse an XML doc and store the results in a DataStructure so I can later iterate over this e.g. Array...I read that XSLT doesnt support Arrays but theres the node-set which will let me do this looping over a subset of the xml stored in the node-set structure?
Can someone give me an example or inform me if theres any other DataStructures that would be suitable for this?
Subject:node-set - Arrays in XSLT? Author:Minollo I. Date:24 Mar 2006 09:31 AM
If you use the "books.xml" file shipped as part of the example Stylus Studio project, you can, as an example, do something like this:
<xsl:template match="/">
<!-- collect all books satisfying some condition in a variable -->
<xsl:variable name="myBooks">
<xsl:for-each select="books/book[@bookid < 3]">
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
<!-- output the title of the first book referenced by the variable -->
<firstOne>
<xsl:value-of select="$myBooks[1]/book/title"/>
</firstOne>
</xsl:template>