View Single Post
  #2 (permalink)  
Old November 22nd, 2007, 04:37 AM
joefawcett's Avatar
joefawcett joefawcett is offline
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Code:
<xsl:template name="select">
    <xsl:param name="options" />
    <xsl:for-each select="exslt:node-set($options)/node()">
      <xsl:copy-of select="name"/>
      <xsl:copy-of select="value"/>
    </xsl:for-each>
  </xsl:template>
But I would use
Code:
exslt:node-set($options)/option">
or
Code:
exslt:node-set($options)/*">
in preference to node() as node() can pick up text nodes.
Alternatively embed the options into the stylesheet under the root element:
Code:
<my:options><option><name>1</name><value>test1</value></option>
<option><name>2</name><value>test2</value></option><my:options>
Then you can select them using
Code:
document('')/*/my:options/option
and dispense with exslt:node-set altogether. Or move to XSLT 2.0 :)

--

Joe (Microsoft MVP - XML)
Reply With Quote