Thanks! I did check  though
8.2 Conditional Processing with xsl:choose
and even 5.7 sequence constructor
because I thought that was what was going on.

so which statement is constructing the new node, xsl:choose or xsl:when?

also, xquery, sequence constructor (parens) do not appear to 'work' the same, sequence seems preserved?


From: Andrew Welch <>
To: Mailing list for the SAXON XSLT and XQuery processor <>
Cc: Paul M <>
Sent: Thursday, May 17, 2012 9:28 AM
Subject: Re: [saxon] saxon or just xslt2.0

On 17 May 2012 14:05, David Rudel <> wrote:
> I suspect in one case your variable is being treated as a virtual document
> node and in the other case it is being treated as a sequence of nodes. This
> is an important nuance I only recently discovered myself.
> You can see the difference by comparing the following:
> <xsl:variable name="testme">
> <xsl:sequence select="a"/>
> <xsl:sequence select="b"/>
> </xsl:variable>

The thing to be aware of is the implicit document node creation within
the variable:

<xsl:variable name="foo">

is the same as:

<xsl:variable name="foo">

In both cases $foo contains a document node with the element <foo/> as a child.

If you specify the sequence constructor (the 'as' attribute) such as:

<xsl:variable name="foo" as="element(foo)">

then $foo now just contains the element <foo/>

If you explicitly create the document node with that same sequence constructor:

<xsl:variable name="foo" as="element(foo)">

....then you get an error because the variable contains a document
node instead of the element <foo/>

So the moral of the story is always specify the 'as' attribute, and if
you really want a document node, then use
as="document-node(root-element)" and explicitly create it.

Andrew Welch