Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this even possible? XSL 1

Status
Not open for further replies.

mike314

Programmer
Jun 24, 2003
143
US
Is there a way in xsl to create an array similar to javascript? Or is there a way similar to store data like an array where you can access it?

thanks
 
You can store data in a seperate XML file, then reference it with document() function. Or you can store a nodeset in a variable.

Jon

"I don't regret this, but I both rue and lament it.
 
how would you create a node set inside a variable?

thanks
 
Code:
<xsl:variable name="myArray">
  <elem>1</elem>
  <elem>2</elem>
  <elem>3</elem>
  <elem>4</elem>
  <elem>5</elem>
</xsl:variable>
Depending on what version of XSL you're using, you'll probably need to use an extension function - nodeset() - to deal with the result tree fragment. The msxsl extension can be used:
Code:
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
Now you can refer to the array (eg 3rd element) as follows:
Code:
<xsl:value-of select="msxsl:nodeset($myArray)/elem[3]"/>

Jon

"I don't regret this, but I both rue and lament it.
 
A lot of the time you don't actually need arrays, you can use recursion. Speeds things up and is neater.

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top