[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: ClassCastException

Subject: Re: ClassCastException
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Sat, 13 Dec 2003 01:23:05 +0100
classcastexception
JCS wrote:
Is there somewhere I can find an example of the difference between a node
set and a result tree fragment?

A node set is a set of nodes grabbed from the a source tree, either the original input, returned by document(), or constructed with an XPath extension function which returns a node set.

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?

I don't understand the question. Some XSLT statements require the XPath expression in the select attribute to evaluate into a node set. I'm not sure what you count as "a path", the expression (/foo|$foo/bar|document('foo.xml')) ought to evaluate in a node set too, provided $foo holds a node set.

J.Pietschmann


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



Current Thread
  • ClassCastException, (continued)
    • alana - Fri, 12 Dec 2003 00:41:15 -0500 (EST)
      • David Carlisle - Fri, 12 Dec 2003 17:01:35 -0500 (EST)
        • JCS - Fri, 12 Dec 2003 17:34:34 -0500 (EST)
        • David Carlisle - Fri, 12 Dec 2003 18:32:23 -0500 (EST)
        • J.Pietschmann - Fri, 12 Dec 2003 19:23:46 -0500 (EST) <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.