I stumbled across this ('this' is explained later) when I
realized that
<xsl:variable name="root">
<test1 />
<test2 />
</xsl:variable>
can be queried by an xpath using the simple $root/* axis. In other
words: children of $root. And that this felt non-analogous to
the following:
<xsl:function name="my:rootless">
<test1 />
<test2 />
</xsl:function>
Yes, it's not analogous.
I would recommend always using an "as" attribute with xsl:variable,
especially when you don't use the select attribute. Think of the (above)
syntax without an "as" attribute as a legacy shorthand for
<xsl:variable name="root" as="document-node()">
<xsl:document>
<test1 />
<test2 />
</xsl:document>
</xsl:variable>
If it weren't for backwards compatibility, I'm sure we would have made
xsl:variable behave the same way as xsl:function, that is in this case, to
return a sequence of two parentless elements - which is what you get if you
write <xsl:variable as="element()*">.
Michael Kay
http://www.saxonica.com/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--