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

Re: Sibling axis and as="element()"

Subject: Re: Sibling axis and as="element()"
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 31 Jul 2006 17:42:31 +0100
Re:  Sibling axis and as="element()"
>  but that do not have a common parent? 
no now they _do_ have a common parent, the document node you generated
with xsl:document.

maybe take a step back. Conceptually the content of xsl:template,
literal result elements xsl:variable etc are all "template bodies" and
are all evaluated the same way (and as attribute does not affect this)
so a content of

	<foo/>
	<foo/>
	<foo/>

generates a sequence of three parentless foo nodes.

Now what happens to the "content sequence" depends of what its content
of, but the _usual_ thing is that boring details like text nodes being
merged happens, and then all nodes are _copied_ to be child nodes of the
containing node in the current result tree.

so in
<bar>
	<foo/>	<foo/>	<foo/>
</bar>
those three foo nodes are copied to be children of bar and at that point
become siblings. (The system probably doesn't really copy them as it
knows in advance the parentless nodes will never be accessed so it
probably can immediately attach them to bar but that's implementation
details )

the situation in

<xsl:document>	<foo/>	<foo/>	<foo/> </xsl;document>
is exactly the same  except now they become children of a / node rather
than an element.

If you have 
<xsl:variable name="foo">
	<xsl:document>
		<foo/>
		<foo/>
		<foo/>
	</xsl:document>
</xsl:variable>

then first you generate the content sequence which in this case is a
sequence of one / node (which happens to have some foo children, but
that does not matter here) then you copy this sequence in as children of
the implict / node, except there is a special rule about copying /
nodes, in that (same as in xslt 1.0) the node itself is not copied, but
rather its children are copied 9as you can not have / being a child
node).

If you have 
<xsl:variable name="foo" as=document-node()>
	<xsl:document>
		<foo/>
		<foo/>
		<foo/>
	</xsl:document>
</xsl:variable>

Then the content sequence is generated as above, and as that is a
seuence of one / node, it matches the specified type and so is accepted,
no copying is done in this case.

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.