This is the mail archive of the
mailing list .
RE: return nodeset to xsl:variable
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] return nodeset to xsl:variable
- From: "Evan Lenz" <elenz at xyzfind dot com>
- Date: Wed, 7 Mar 2001 16:02:15 -0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
Well, you can use the select attribute of xsl:variable like so:
<xsl:variable name="x" select="foo/bar"/>
$x will return the node-set selected by the above XPath expression.
But if you want to create an arbitrary node-set (not from the original
source document), you can't do that without an extension function. This is
because the content of xsl:variable (and named templates, etc.) only
instantiates a result tree fragment (RTF), which is what you're doing when
you "return a string". However, most XSLT processors provide an extension
that allows you to access that result tree fragment as a node-set.
You could then do something like this:
Note that the node-set identified by saxon:node-set($x) is a node-set
containing only one node, namely the root node of a new tree. From that
root, you can drill down into the tree, as in the above XPath expression.
XSLT 1.1 will take away the need for the node-set extension function so that
you will always be able to access arbitrarily constructed trees as node-sets
(that contain one root node). This eliminates the RTF type from XSLT. You'll
be able to do, simply:
While this effectively enables you to access arbitrarily constructed nodes,
it doesn't really allow you complete freedom in arbitrary node-set
construction, because it always returns just one newly-constructed root
node. Since it only contains the root node of a new tree, it can't, by
itself, return a node-set that also contains nodes from the source tree.
I think that the other discussions on this list regarding "EXSLT" begin to
address this issue. There's a desire for a user-defined function mechanism
that might return arbitrarily-constructed node-sets.
For many use cases, however, a node-set() extension function (and later,
XSLT 1.1) should be all you need.
Hope this helps,
> -----Original Message-----
> From: firstname.lastname@example.org
> [mailto:email@example.com]On Behalf Of Paul Bell
> Sent: Wednesday, March 07, 2001 3:19 PM
> To: firstname.lastname@example.org
> Subject: [xsl] return nodeset to xsl:variable
> Hi All,
> I see how to set an xsl:variable by 'returning' a string from a called
> template, but how do you return a node set to an xsl:variable?.
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list