#408 Adding documents to a document

v8.5.1
closed
Michael Kay
5
2012-10-08
2005-09-14
Michael Kay
No

When the sequence constructor generating the children
of a new document node itself contains a document node,
and there are elements following that document node,
then the tree that is constructed is malformed, and the
elements appear not to be there (they are not selected
when following the child axis from the containing
document node). For example, with

<xsl:variable name="x">
<xsl:copy-of select="document('abc.xml')"/>
<xyz/>
</xsl:variable>

the variable $x will appear to contain a copy of the
document abc.xml, but no xyz element.

The problem could also appear in XQuery, though it's
less likely. This bug first appeared in Saxon 8.5.

Circumvention: copy the children of the document node,
not the document node itself, thus:

<xsl:variable name="x">
<xsl:copy-of select="document('abc.xml')/node()"/>
<xyz/>
</xsl:variable>

Michael Kay

Discussion