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

Re: xsl:sequence

Subject: Re: xsl:sequence
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 8 Aug 2006 11:20:27 +0100
Re:  xsl:sequence
> If I'm retreiving the value of a text node where I don't need to navigate 
> away from it, I'm not worried about performance and I didn't need to do an 
> identity-related operation I presume I perfectly OK to use value-of or 
> copy-of but there seems to be little point.

value-of and copy-of are the same thing on a text node (although it's
normally fairly rare to access text nodes directly, some people tend to
over-use text() it makes the stylesheet rather fragile as it means that
source files with comments in often fail  given
<foo>onetwo</foo>
<xsl:value-of select="foo"/> and <xsl:value-of select="foo/text()"/>
both generate a text node with value "onetwo". But given
<foo>one<!-- hmm -->two</foo>
<xsl:value-of select="foo"/> generates a text node with value "one two"
<xsl:value-of select="foo/text()"/> generates a text node with value
"one two" in 2.0 mode or "one" in 1.0 compatibility mode.
So unless you intend your code to do something different in the presence
of comments then it's usually better just to select the element.


> But is the following true: an element node's consists of the name of the 
> element; a text node consists of the CDATA assigned to that node; But an 
> attribute node consists of the name of an attribute *as well* as its CDATA - 
> is this not inconsistent?

Nodes have various properties, as well as unique identies (element nodes
can have the same name and content but are not equal (as tested by the
is operator) unless they are "really" the same node.
attribute, text, processing instruction and comment nodes all have
simple content, that is, they have a string valued property (which is
what you mean by CDATA above, although the term CDATA isn't used in XSL
and means something slightly different in XML) element nodes and
document nodes have complex content, so they do not have a string valued
property (their string value is derived from the string value of their
children) they do have other properties, notably properties listing the
child and attribute nodes.

> Am I delving into things I shouldn't be delving into here?
Not at all, it seems to me you are asking how xslt works which couldn't
be more on topic for this list.

David

Current Thread

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.