[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 11:43:09 GMT
Re:  Question about variable definition and types
> So
> 
> <xsl:variable name="foo" as="document-node()">
>    <a/>
>    <b/>
> </xsl:variable>
> 
> would be the equivalent of (identical to?) an un-typed variable and  
> allow siblings?

No you get a type error in that case, that you have specified a document
node but generated element nodes (the document node generation is only
implicit in the "legacy" usage without an as)

You'd need to do

<xsl:variable name="foo" as="document-node()">
<xsl:document>
   <a/>
   <b/>
</xsl:document>
</xsl:variable>

To explictly make the node.


But the main difference between the usage with and without as= is not
that the nodes in teh variable are siblings, it's that they are (or are
not) copies.

If you go

<xsl:variable name="a1">
  <xsl:sequence select="a"/>
</xsl:variable>


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



Then in both cases the a element nodes are siblings, but 

in $a1 they are _copies_ of nodes from the input copied into a new
temporary tree and so are the only siblings of the new / node at the top
of that tree.

in $a2 they are the original a nodes in the source document (so
necessarily siblings as they are selected by the xpath "a" so all
children of the current node at that point. In this case $a2 holds these
nodes, and they are (still) siblings, but they may have other siblings
not contained in the variable, and their parent node is similarly not
cotained in the variable. 

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.