Processing a Tree Fragment as a Tree by Using msxsl:node-set()
According to the XSLT specification, you can do only two things with a result tree fragment that is returned as the value of an <xsl:variable>
or <xsl:param>
element: copy the fragment to the result tree, or treat it as a string.
Often, however, you will want to treat the fragment as a tree or sub-tree, to enable processing by a further step (such as sorting or accumulating a sum).
To treat a result tree fragment as a tree or sub-tree
- Declare the
msxsl:
namespace. For more information, see Declaring the msxsl: Namespace Prefix. - Establish the result tree fragment, using a variable or parameter.
- Convert the result tree fragment to a node-set, using the
msxsl:node-set()
function. - Use the converted node-set as you would use any other node-set, in XPath expressions, function calls, and so on.
The following is a simple example of Step 4.
<xsl:value-of select="msxsl:node-set($emprecs)/employee
"/>
This example treats the variable or parameter called $emprecs
as if it were a tree of nodes. An instance of an <employee>
child of that tree of nodes is created in the result tree.