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/
Editor:
Michael Kay, Saxonica <http://www.saxonica.com/>

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


Abstract

This document defines methods of serializing an instance of the data model defined in [XDM 4.0] into a sequence of octets, conforming to a variety of formats including XML, HTML, and JSON. Serialization is designed to be a component that can be used either on its own, or invoked from languages such as [XSLT 4.0], [XPath 4.0] or [XQuery 4.0].

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document.

This document is a working draft developed and maintained by a W3C Community Group, the XQuery and XSLT Extensions Community Group unofficially known as QT4CG (where "QT" denotes Query and Transformation). This draft is work in progress and should not be considered either stable or complete. Standard W3C copyright and patent conditions apply.

The community group welcomes comments on the specification. Comments are best submitted as issues on the group's GitHub repository.

The community group maintains two extensive test suites, one oriented to XQuery and XPath, the other to XSLT. These can be found at qt4tests and xslt40-test respectively. New tests, or suggestions for correcting existing tests, are welcome. The test suites include extensive metadata describing the conditions for applicability of each test case as well as the expected results. They do not include any test drivers for executing the tests: each implementation is expected to provide its own test driver.

Dedication

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


9 JSON Output Method

Changes in 4.0 (next | previous)

  1. Added the escape-solidus parameter for JSON serialization.   [Issue 530 PR 534 6 June 2023]

  2. Added the json-lines parameter for JSON serialization.   [Issue 1471  15 October 2024]

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

  4. A JNode is replaced by its ·content· property.   [Issue 2025 PR 2031 29 May 2025]

  5. JSON canonicalization is supported by the ·canonical· property.   [Issue 938 PR TODO 20 October 2025]

  6. The JSON output method now produces fallback representation of NaN and infinity, rather than reporting an error for such values.   [Issue 641 PR 2387 16 January 2026]

The JSON output method serializes the input tree using the JSON syntax defined in [RFC 7159], or (if the json-lines parameter is set to true) the json-lines syntax defined at [JSON Lines]. Sequence normalization is not performed for this output method. The effect of the json-lines parameter is explained at 9.2 JSON Lines.

If json-lines is set to false, then:

G Change Log (Non-Normative)

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

  1. If a section of this specification has been updated since version 3.1, an overview of the changes is provided, along with links to navigate to the next or previous change.

    See 1 Introduction

  2. Sections with significant changes are marked with a ✭ symbol in the table of contents.

    See 1 Introduction

  3. PR 2114 2226 

    A JNode is represented as jnode(K: V) where K is its ·selector· property and V is its ·content· property.

    See 10 Adaptive Output Method

  4. The JSON output method now produces fallback representation of NaN and infinity, rather than reporting an error for such values.

    See 9 JSON Output Method

  5. PR TODO 

    Added the canonical parameter for XML, XHTML, and JSON serialization.

    See 3 Serialization Parameters

    JSON canonicalization is supported by the ·canonical· property.

    See 9 JSON Output Method

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

    See 10 Adaptive Output Method

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

    See 1.1 Terminology

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

    See 3 Serialization Parameters

    See 9 JSON Output Method

  8. 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

  9. 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

  10. PR 1703 

    The serialization of maps retains the order of entries.

    See 9 JSON Output Method

    See 10 Adaptive Output Method

  11. 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

  12. PR 2031 

    A JNode is replaced by its ·content· property.

    See 9 JSON Output Method

  13. PR 2387 

    The JSON output method now produces fallback representation of NaN and infinity, rather than reporting an error for such values.

    See 9 JSON Output Method