XML 1.1
XML 1.1 (with XML Namespaces 1.1) originally extended XML 1.0 in three ways:
-
the set of valid characters is increased
-
the set of characters allowed in XML Names is increased
-
namespace undeclarations are permitted
The second change has subsequently been retrofitted to XML 1.0 Fifth Edition (XML 1.0e5). Saxon now uses the XML 1.1 and XML 1.0e5 rules unconditionally for all validation of XML names.
XML 1.1 input documents
Saxon is capable of working with XML 1.1 input documents, provided that the XML parser supports XML 1.1.
On Java, the built-in XML parser and the commonly-used Apache Xerces both support XML 1.1
SaxonCS works only with the Microsoft
System.Xml.XmlReader
parser, which does not support XML 1.1
Configuration
If you want to use Saxon with XML
1.1, you should set the option -xmlversion:1.1
on the Saxon command line, or
set the configuration option XML_VERSION.
This configuration setting affects:
-
the characters considered valid in the source of an XQuery query
-
the characters considered valid in the result of the functions
codepoints-to-string()
andunparsed-text()
-
the characters considered valid in the result of certain Saxon extension functions
-
the way in which line endings in XQuery queries are normalized
-
the default version used by the serializer (with output method XML)
Since Saxon 9.4, the configuration setting no longer affects:
-
validation of names used in XQuery and XPath expressions, including names of elements, attributes, functions, variables, and types
-
validation of names of constructed elements, attributes, and processing instructions in XQuery and XSLT
-
schema validation of values of type
xs:NCName
,xs:QName
,xs:NOTATION
, andxs:ID
-
the permitted names of stylesheet objects such as keys, templates, decimal-formats, output declarations, and output methods.
Note that if you use the default setting of "1.0", then supplying an XML 1.1 source document as input may cause undefined errors.
It is advisable to use an XML parser that supports XML 1.1 when the configuration is set to "1.1", and an XML parser that does not support XML 1.1 when the configuration is set to "1.0". However, Saxon does not enforce this.
Data model
In the XDM data model for representation of XML documents, it is possible to have namespaces that are in scope for a parent element, but not in scope for its children. This is supported by the native Saxon tree models (the TinyTree and LinkedTree), but not by most third-party tree models (DOM, XOM, JDOM2, etc). It is possible to create such trees using XSLT or XQuery, but they will never be produced by an XML 1.0 parser. Such trees can be serialized either as XML 1.0 or XML 1.1: if XML 1.0 is chosen, the namespace undeclarations used to indicate absent namespace bindings will simply be omitted from the output.
The choice of XML 1.0 or 1.1 also affects the set of characters permitted in strings, and in XML text and attribute nodes. Many (but not all) mechanisms for constructing strings check that if the configuration is set to XML 1.0, only permitted XML 1.0 characters may appear.
Serialization
The serialization property version="1.0 | 1.1"
may be set on the xsl:output
and xsl:result-document
elements, and on various APIs. The default depends on the setting
in the Saxon Configuration
.
You can set the configuration to allow XML 1.1, but still serialize result documents as XML
1.0 by specifying the output property version="1.0"
. In this case Saxon will
check while serializing the document that it conforms to the XML 1.0 constraints (note that
this check can be expensive). These checks are not performed if the configuration default is
set to XML 1.0.
If you want the serializer to output namespace undeclarations, use the output property
undeclare-namespaces="yes"
as well as version="1.1"
.
It is not possible to serialize an XDM document as XML 1.0 if it contains text or attribute nodes using characters that XML 1.0 disallows.