This document defines serialization of the W3C XQuery and XPath Data Model 3.1 (XDM), which is the data model of at least [XML Path Language (XPath) 3.1], [XSL Transformations (XSLT) Version 3.0], and [XQuery 3.1: An XML Query Language], and any other specifications that reference it.
In this document, examples and material labeled as "Note" are provided for explanatory purposes and are not normative.
Serialization is the process of converting an instance of the [XQuery and XPath Data Model (XDM) 3.1] into a sequence of octets. Serialization is well-defined for most data model instances.
In this specification, where they appear in upper case, the words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", "MAY", "REQUIRED", and "RECOMMENDED" are to be interpreted as described in [RFC2119].
[Definition: As is indicated in 12 Conformance, conformance criteria for serialization are determined by other specifications that refer to this specification. A serializer is software that implements some or all of the requirements of this specification in accordance with such conformance criteria.] A serializer is not REQUIRED to directly provide a programming interface that permits a user to set serialization parameters or to provide an input sequence for serialization. In this document, material labeled as "Note" and examples are provided for explanatory purposes and are not normative.
Certain aspects of serialization are described in this specification as implementation-defined or implementation-dependent.
[Definition: Implementation-defined indicates an aspect that MAY differ between serializers, but whose actual behavior MUST be specified either by another specification that sets conformance criteria for serialization (see 12 Conformance) or in documentation that accompanies the serializer.]
[Definition: Implementation-dependent indicates an aspect that MAY differ between serializers, and whose actual behavior is not REQUIRED to be specified either by another specification that sets conformance criteria for serialization (see 12 Conformance) or in documentation that accompanies the serializer.]
[Definition: In some instances, the sequence that is input to serialization cannot be successfully converted into a sequence of octets given the set of serialization parameter (3 Serialization Parameters) values specified. A serialization error is said to occur in such an instance.] In some cases, a serializer is REQUIRED to signal such an error. What it means to signal a serialization error is determined by the relevant conformance criteria (12 Conformance) to which the serializer conforms. In other cases, there is an implementation-defined choice between signaling a serialization error and performing a recovery action. Such a recovery action will allow a serializer to produce a sequence of octets that might not fully reflect the usual requirements of the parameter settings that are in effect.
[Definition: Where this specification indicates that two strings are to be compared without regard to case, the serializer MUST translate any characters in the range #x41 (LATIN CAPITAL LETTER A) to #x5A (LATIN CAPITAL LETTER Z), inclusive, to the corresponding lower-case letters in the range #x61 (LATIN SMALL LETTER A) to #x7A (LATIN SMALL LETTER Z) only for the purposes of making the comparison. The comparison succeeds if the two strings are the same length and the code point of each character in the first string is equal to the code point of the character in the corresponding position in the second string.]
Many terms used in this document are defined in the XPath specification [XML Path Language (XPath) 3.1] or the Data Model specification [XQuery and XPath Data Model (XDM) 3.1]. Particular attention is drawn to the following:
[Definition: The term atomization is defined in Section 2.4.2 Atomization XP31. ]
[Definition: The term node is defined as part of Section 6 Nodes DM31. There are seven kinds of nodes in the data model: document, element, attribute, text, namespace, processing instruction, and comment.]
[Definition: The term sequence is defined in Section 2 Basics XP31. A sequence is an ordered collection of zero or more items.]
[Definition: The term function is defined in Section 2.8.1 Functions DM31.]
[Definition: The term map item is defined in Section 2.8.2 Map Items DM31.]
[Definition: The term array item is defined in Section 2.8.3 Array Items DM31.]
[Definition: The term string is defined in Section 2.7.3 XML and XSD Versions DM31.]
[Definition: The term character is defined in Section 2.7.3 XML and XSD Versions DM31.]
[Definition: The term codepoint is defined in Section 2.7.3 XML and XSD Versions DM31.]
[Definition: The term string value is defined in Section 5.12 string-value Accessor DM31. Every node has a string value. For example, the string value of an element is the concatenation of the string values of all its descendant text nodes.]
[Definition: The term expanded QName is defined in Section 2 Basics XP31. An expanded QName consists of an optional namespace URI and a local name. An expanded QName also retains its original namespace prefix (if any), to facilitate casting the expanded QName into a string.]
[Definition: An expanded-QName whose namespace part is an empty sequence, or an element or attribute whose name expands to such an expanded-QName, is referred to as having a null namespace URI].
[Definition: An element or attribute that does not have a null namespace URI, is referred to as having a non-null namespace URI].
[Definition: A space character, TAB character, CR character or NL character is referred to as a whitespace character.]
Where this specification indicates that an XSLT instruction is evaluated, the behavior is as specified by [XSL Transformations (XSLT) Version 3.0]. Where it indicates that an XQuery expression is evaluated, the behavior is as specified by [XQuery 3.1: An XML Query Language].
This specification refers to several namespaces that affect the process of serialization. These are:
[Definition: the
Output declaration namespace,
https://www.w3.org/2010/xslt-xquery-serialization
];
[Definition: the
XML namespace,
https://www.w3.org/XML/1998/namespace
];
[Definition: the
XHTML namespace namespace,
https://www.w3.org/1999/xhtml
];
[Definition: the
SVG namespace,
https://www.w3.org/2000/svg
]; and
[Definition: the
MathML namespace namespace,
https://www.w3.org/1998/Math/MathML
.]
Wherever an element node or attribute node is said to be in a particular namespace, it is understood that the namespace URI of the node is equal to the namespace URI corresponding to that namespace. Wherever a namespace node is said to be a namespace node for a particular namespace, it is understood that the string value of the node is equal to the namespace URI corresponding to that namespace.