View Old View New View Both View Only Previous Next

This draft contains only sections that have differences from the version that it modified.

W3C

XSLT and XQuery Serialization 4.0

W3C Editor's Draft 23 February 2026

This version:
https://www.w3.org/TR/2000/REC-xslt-xquery-serialization-40-20000101/
Latest version of XSLT and XQuery Serialization 4.0:
https://www.w3.org/TR/xslt-xquery-serialization-40/
Most recent version of XSLT and XQuery Serialization 4:
https://www.w3.org/TR/xslt-xquery-serialization-4/
Most recent version of XSLT and XQuery Serialization:
https://www.w3.org/TR/xslt-xquery-serialization/
Most recent Recommendation of XSLT and XQuery Serialization:
https://www.w3.org/TR/xslt-xquery-serialization-31/
Editors:
Andrew Coleman, IBM Hursley Laboratories <andrew_coleman@uk.ibm.com>
C. M. Sperberg-McQueen, Black Mesa Technologies <http://blackmesatech.com/>

Please check the errata for any errors or issues reported since publication.

See also translations.

This document is also available in these non-normative formats: XML.


Abstract

This document defines serialization of an instance of the data model as defined in [XQuery and XPath Data Model (XDM) 4.0] into a sequence of octets. Serialization is designed to be a component that can be used by other specifications such as [XSL Transformations (XSLT) Version 4.0] or [XQuery 4.0: An XML Query Language].

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.

This document is governed by the 1 March 2017 W3C Process Document.

This is a Recommendation of the W3C. It was jointly developed by the W3C XSLT Working Group and the W3C XML Query Working Group, each of which is part of the XML Activity.

This Editor's Draft specifies XSLT and XQuery Serialization version 4.0, a fully compatible extension of Serialization version 3.1.

This specification is designed to be referenced normatively from other specifications defining a host language for it; it is not intended to be implemented outside a host language. The implementability of this specification has been tested in the context of its normative inclusion in host languages defined by the XQuery 3.1 and XSLT 3.0 specifications; see the XQuery 3.1 implementation report (and, in the future, the WGs expect that there will also be an XSLT 3.0 implementation report) for details.

No substantive changes have been made to this specification since its publication as a Proposed Recommendation.

Please report errors in this document using W3C's public Bugzilla system (instructions can be found at https://www.w3.org/XML/2005/04/qt-bugzilla). If access to that system is not feasible, you may send your comments to the W3C XSLT/XPath/XQuery public comments mailing list, public-qt-comments@w3.org. It will be very helpful if you include the string “[SER40]” in the subject line of your report, whether made in Bugzilla or in email. Please use multiple Bugzilla entries (or, if necessary, multiple email messages) if you have more than one comment to make. Archives of the comments and responses are available at https://lists.w3.org/Archives/Public/public-qt-comments/.

This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web.

This document was produced by groups operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures (W3C XML Query Working Group) and a public list of any patent disclosures (W3C XSLT Working Group) made in connection with the deliverables of each group; these pages also include instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

Dedication

The publications of this community group are dedicated to our co-chair, Michael Sperberg-McQueen (1954–2024).


10 Adaptive Output Method

Changes in 4.0  

  1. The serialization of maps retains the order of entries.   [Issue 1651 PR 1703 14 January 2025]

  2. The output of QNames reflects the new syntax for QName literals.   [Issue 2059 PR TODO 23 June 2025]

  3. A JNode is represented as jnode(X) where X is its ·content· property.   [IssuesIssue 2025 2087 PR 20312114 29 May22 June 2025]

The Adaptive output method serializes the input tree into a human readable form for the purposes of debugging query results. The intention of this is to allow any input value to be serialized without raising a serialization error. Sequence normalization is not performed for this output method.

Each item in the supplied sequence is serialized individually as follows, with an occurrence of the chosen item-separator between successive items.

Character maps are applied (a) when nodes are serialized using the XML output method, and (b) to any value represented as a string enclosed in quotation marks.

Optionally, in all the above constructs, characters whose visual representation is ambiguous (for example tab or non-breaking-space) may be represented in the form of an XML numeric character reference (for example &#x9; or &#xa0;)

Note:

In many cases the serialization of an item conforms to the syntax of an XQuery expression whose result is that item. There are exceptions, however. For example, the syntax will not be valid XQuery in the case of free-standing attribute or namespace nodes, or QName values, or anonymous functions; and where it is valid XQuery, the result of evaluating the expression will not necessarily be identical to the original: for example, the distinction between strings and untypedAtomic items is lost.

If any value cannot be output because doing so would cause a serialization error, the behavior is implementation-defined.

If the output is sent to a destination that allows hyperlinks to be included in the generated text, then the serializer may include implementation-dependent hyperlinks to provide additional information for example:

G Change Log (Non-Normative)

This appendix lists changes made in version 4.0 of this specification.

  1. Use the arrows to browse significant changes since the 3.1 version of this specification.

    See 1 Introduction

  2. Sections with significant changes are marked Δ in the table of contents.

    See 1 Introduction

  3. The term atomic value has been replaced by atomic item.

    See 1.1 Terminology

  4. Added the json-lines parameter for JSON serialization.

    See 3 Serialization Parameters

    See 9 JSON Output Method

  5. PR TODO 

    The output of QNames reflects the new syntax for QName literals.

    See 10 Adaptive Output Method

  6. PR 342 

    In the HTML and XHTML output methods, the rules for adding and replacing meta elements have been revised to take account of the new HTML5 syntax, for example <meta charset="utf-8">.

    See 6 XHTML Output Method

    See 7 HTML Output Method

  7. PR 534 

    Added the escape-solidus parameter for JSON serialization.

    See 3 Serialization Parameters

    See 9 JSON Output Method

    See 10.1 The Influence of Serialization Parameters upon the Adaptive Output Method

  8. PR 1703 

    The serialization of maps retains the order of entries.

    See 9 JSON Output Method

    See 10 Adaptive Output Method

  9. PR 1977 

    The default HTML version is now 5. This may result in changes to the serialized output in cases where no explicit HTML version is requested.

    See 6 XHTML Output Method

    See 7 HTML Output Method

  10. PR 2031 

    A JNode is replaced by its ·content· property.

    See 9 JSON Output Method

  11. PR 2031 2114 

    A JNode is replaced by its ·content· property.

    See 9 JSON Output Method

    A JNode is represented as jnode(X) where X is its ·content· property.

    See 10 Adaptive Output Method