Re: [xsl] node-set = node-set involving variable fails

Subject: Re: [xsl] node-set = node-set involving variable fails
From: David N Bertoni/Cambridge/IBM <david_n_bertoni@xxxxxxxxxx>
Date: Fri, 8 Nov 2002 15:08:18 -0800



Roger Glover <glover_roger@xxxxxxxxx> wrote:
> I discovered the "nodeset()" extension function in Xalan, so now my joy
is
> complete, even though my XSLT Recommendation compliance is not.

You can have your cake and eat it too by replacing xsl:variable with some
regular elements:

   <?xml version="1.0"?>
   <xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
     xmlns:foo="http://myURI.foo.com";
     exclude-result-prefixes="foo"
     version="1.0">

   <foo:var name="targets">
       <target>target1</target>
       <target>target2</target>
           <!-- ...... -->
       <target>target93</target>
   </foo:var>

   <xsl:variable name="targets"
       select="document('')/*/foo:var[@name = 'targets']"/>

   <xsl:template match="/">
     <out>
       <xsl:for-each select="$targets/*">
         <xsl:text>&#xA;</xsl:text>
         <target>
            <xsl:value-of select="."/>
         </target>
       </xsl:for-each>
       <xsl:text>&#xA;</xsl:text>
     </out>
   </xsl:template>

   </xsl:stylesheet>

The xsl:for-each is there just to demonstrate that the variable is really a
node-set.

Not tested, but you get the idea! ;-)

Dave


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread