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

Re: Question about variable definition and types

Subject: Re: Question about variable definition and types
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 7 Mar 2008 15:10:26 GMT
Re:  Question about variable definition and types
> If I process the content of $a2 I would assume that preceding/ 
> following-sibling axis only "sees" the siblings in the variable.

No, it will go off and traverse the original document.
The same feature was present in XSLt 1.

Going

 <xsl:variable name="a2" as="element()*">
   <xsl:sequence select="a"/>
 </xsl:variable>

Is exactly the same as going

 <xsl:variable name="a2" select="a"/>

which even in xslt1 stores a set of a nodes in their original context.

the only new feature is that in xslt2 you can use the content of
xsl:variable as an alternative to the select attribute, which gives the
possibility of using control constructs such as xsl;choose, not so
easily available in xpath.

this feature of allowing content as an alternative to select attribute
is a general feature of xslt2, see xsl:attribute, xsl:value-of etc.
The only complication was xsl:variable where content was already alowed
(but with the different semantics of implying a document node) so here
the
"new style" semantics of the content being a replacement for the select
expression only applies when there is an as attribute.


> How would I access the preceding/following siblings from "inside" the  
> variable with the as attribute?

If you want the nodes inside the variable to be siblings (and have no
other siblings) then you need to copy them rather than refer to the
original nodes. The siblings of a node are a property of that node
so if you want a node which has different siblings, you don't want to
refer to the original node, you need a copy.


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-2011 All Rights Reserved.