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

Re: when to use 'as' attribute on a variable

Subject: Re: when to use 'as' attribute on a variable
From: "tom tom" <tomxsllist@xxxxxxxxxxx>
Date: Wed, 08 Mar 2006 13:43:34 +0000
when to use as
To store an external XML doc in a variable am I right in saying I should use document-node() ?

yes

So what advantage does document-node() give me over element(), node(), or item()??


item() includes atomic types such as integers so 1 (an integer) and "1"
(a string) are both of type item() but not of type node()

In XPath 1 <xsl:value-of select="node()"/> would return the value of the text nodes - presumably the node() you are referring to is a completely different data type and unrelated?



From: David Carlisle <davidc@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  when to use 'as' attribute on a variable
Date: Wed, 8 Mar 2006 11:08:38 GMT

> To store an external XML doc in a variable am I right in saying I should use
> document-node() ?


yes

> To store an nodeset taken from the XML in a variable I should use item()?

XPath2 doesn't have node sets (They are the XPath1 datatype) it has
sequences. The nearest type to a node set is a sequence of nodes which
is node()*. If you need to store a sequence of nodes you can use node()*
but if your "nodeset" is just a single top level element then you can
use more specific types such as node() or element().

> Then what is the node()

see above

> type for and how is it different from item()?

item() includes atomic types such as integers so 1 (an integer) and "1"
(a string) are both of type item() but not of type node() the type
item()*
is a sequence of items and is the most general type, all XPath2 values
match that type.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


_________________________________________________________________
Be the first to hear what's new at MSN - sign up to our free newsletters! http://www.msn.co.uk/newsletters


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.