Bug #4647

omit-xml-declaration for adaptive serialization

Added by Debbie Lockett 29 days ago. Updated 19 days ago.

Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
10, 9.9
Fix Committed on Branch:
Fixed in Maintenance Release:


For adaptive serialization, setting the omit-xml-declaration parameter has no affect. XML declarations are never output when serializing nodes, so in effect the default is "true", and setting the parameter to "false" has no affect (i.e. this does not force XML declarations to be included).

For instance, try amending the XSLT30 test result-document-0304. The test was relatively recently amended to explicitly set omit-xml-declaration="true" on the xsl:result-document instruction. Removing the parameter, or changing it to set omit-xml-declaration="false" has no affect on the result.

Note that the expected default depends on where the serialization comes from.

The XSLT 3.0 specification says that the default for omit-xml-declaration is false (

"The value of the omit-xml-declaration attribute provides the value of the omit-xml-declaration parameter to the serialization method. The default value is no."

Meanwhile the XQuery 3.1 specification, under "D. Implementation-Defined items" (, says that the default is implementation-defined:

"The following items in this specification are implementation-defined: [...]

  1. The default values for the byte-order-mark, encoding, html-version, item-separator, media-type, normalization-form, omit-xml-declaration, standalone, and version parameters, if the Serialization Feature is supported."

(And the Saxon documentation does not explicitly state what these defaults are at!conformance/xquery31)

While the specification for the fn:serialize function, says the default for omit-xml-declaration is different again: (

"If the second argument is omitted, or is supplied in the form of an output:serialization-parameters element, then the values of any serialization parameters that are not explicitly specified is ·implementation-defined·, and may depend on the context."

"If the second argument is supplied as a map [...] The required type of each parameter, and its default value, are defined by the following table." And the table says that here the default for omit-xml-declaration is "yes" i.e. true()."


#1 Updated by Michael Kay 20 days ago

The spec for the adaptive method is a bit illogical here. "The encoding parameter is not directly applicable to the Adaptive output method." (so what encoding should it use?) but the encoding presumably finds its way into any XML declarations included in the result, whether or not that encoding is the one actually used.

I thing the reason fn:serialize() defaults omit-xml-declaration to "yes" is that the output of fn:serialize() is a string, therefore it has no particular encoding, and therefore any XML declaration would be misleading.

#2 Updated by Debbie Lockett 19 days ago

The section "10.1 The Influence of Serialization Parameters upon the Adaptive Output Method" in the serialization spec begins by saying:

"For some item types the Adaptive output method will delegate serialization to other output methods. With the exception of the byte-order-mark serialization parameter, all serialization parameters, if set, will be passed down to the serialization method that is applied to each item in the supplied sequence. Only the item-separator and byte-order-mark parameters are directly applicable to the Adaptive output method."

So yes, the encoding, like other serialization properties, should be passed down and used.

Please register to edit this issue

Also available in: Atom PDF