The XSLT 3.0 specification says (in §23.1):
If the xsl:message instruction contains a sequence constructor, then
the sequence obtained by evaluating this sequence constructor is used
to construct the content of the new document node, as described in
5.7.1 Constructing Complex Content.
And 5.7.1 says that attempting to attach an attribute node to a document node is an error.
§23.1 goes on to say:
Any dynamic error that occurs while evaluating the select expression
or the contained sequence constructor, and any serialization error
that occurs while processing the result, does not cause the
transformation to fail; at worst, it means that no message is output,
or that the only message that is output is one that relates to the
error that occurred.
and this is what Saxon does: it outputs the error message as the content of the xsl:message
instruction, and the transformation continues on its way.
The Note that immediately follows describes this very situation, where xsl:message
attempts to output an attribute node. But the Note is incorrect in stating that it is implementation-defined whether or not they are signaled to the user and whether they cause termination of the transformation -- the normative text is clear that the error is never fatal.
So Saxon is behaving in a way that is consistent with the specification, although arguably one could do better, for example by serializing the value passed to xsl:message
using the adaptive serialization method.
I'm not sure why it changed between releases.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…