xsl-list
[Top] [All Lists]

Re: node-set = node-set involving variable fails

2002-11-08 16:08:18




Roger Glover <glover_roger(_at_)yahoo(_dot_)com> 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[(_at_)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



<Prev in Thread] Current Thread [Next in Thread>