[Home] [By Thread] [By Date] [Recent Entries]
JCS wrote:
Is there somewhere I can find an example of the difference between a node set and a result tree fragment?
A result tree fragment (RTF) is a tree constructed in a style sheet variable. If you use xsl:variable without the select attribute, you are always creating a RTF. RTFs can only be created in stylesheet variables. This puts a node set into the variable <xsl:variable name="foo" select="/foo"/> This variable holds a string: <xsl:variable name="foo" select="'/foo'"/> This constructs a RTF. It holds a text node as the single child of the root node of the RTF. The root node of a RTF is similar to the root node of a source tree <xsl:variable name="foo">/foo</xsl:variable> While dereferencing this variable gets the same value as for the variable above in all useful situations, they are different. This constructs a RTF too. It contains eleent nodes as the
children of the root node:
<xsl:variable name="foo">
<xsl:copy-of select="/foo"/>
</xsl:variable>If you now think the distinction between a node set and a RTF is silly, then you may have a point. The spec authors thought treating RTFs the same as source trees might prove difficult and/or prevent optimizations, and they decided to play safe: A RTF can only be copied into the result tree or used via string conversion in an XPath expression, which means you can't select nodes from them. The following expression will always be valid, regardless which of the for forms above is used. concat($foo,'/bar') If the source xml was <foo>/foo</foo> the result is always the same, the string "/foo/bar". Is a node set just a "path", or set of nodes with only one "destination" node vs. a result tree that gives multiple node sets?
J.Pietschmann XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|

Cart



