Subject: Re: [xsl] Sibling axis and as="element()" From: "andrew welch" <andrew.j.welch@xxxxxxxxx> Date: Mon, 31 Jul 2006 16:35:27 +0100 |
> Is this the case? Do parentless trees lose their axes? if you aint got a parent you aint got a brother, it's just a matter of biology:-)
If you use xsl:variable with content and no as attribute then (for xslt1 compatibility) an implict document node is created, and any nodes generated are made children of that document node, so as a consequence of that they become siblings of each other.
If you use an as attribute then the implict document node is not generated and the result is a sequence. In your case the sequence is of newly constructed, parentless nodes so they are not siblings. In this case they have no siblings at all, but in other cases they could have siblings but not in the variable.
If your input looks like
<x> <a><b/></c/></a> <a><b/></c/></a> <a><b/></c/></a> </x>
and your variable looks like
<xsl:variable name="x" as="element()*"> <xsl:sequence select="/x/a/b"/> </xsl:variable>
then the $x is the same as if you'd have gone
<xsl:variable name="x" select="/x/a/b"/>
and (as in 1.0) you'd have a sequence of 3 b elements, and they'd all have siblings which are c elements which are not in the sequence (aka node set) bound to the variable.
Thanks for the explanation. Rather than have implicit document node creation how do you go about making it explicit - what should the as attribute be?
<xsl:variable name="foo" as="...."> <foo/> <foo/> ....
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sibling axis and as="elem, David Carlisle | Thread | Re: [xsl] Sibling axis and as="elem, David Carlisle |
RE: [xsl] Calender support, cknell | Date | Re: [xsl] Sibling axis and as="elem, David Carlisle |
Month |