From c58b5b8b7fef3859b4bc8a7e819ad03ecde918f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gr=C3=BCn?= Date: Tue, 29 Oct 2024 19:38:47 +0100 Subject: [PATCH] JSON Serialization: json-lines. Closes #1471 (#1497) --- .../src/function-catalog.xml | 12 ++++ .../xslt-xquery-serialization-40/src/bibl.xml | 6 ++ .../schema-for-serialization-parameters.xsd | 10 +++ .../src/xslt-xquery-serialization.xml | 66 ++++++++++++------- 4 files changed, 70 insertions(+), 24 deletions(-) diff --git a/specifications/xpath-functions-40/src/function-catalog.xml b/specifications/xpath-functions-40/src/function-catalog.xml index c3c4b8832..db349864c 100644 --- a/specifications/xpath-functions-40/src/function-catalog.xml +++ b/specifications/xpath-functions-40/src/function-catalog.xml @@ -19119,6 +19119,18 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF] absent + + + json-lines + + + xs:boolean? + + true() means "yes", false() means "no" + + no + + json-node-output-method diff --git a/specifications/xslt-xquery-serialization-40/src/bibl.xml b/specifications/xslt-xquery-serialization-40/src/bibl.xml index e7492dd5d..96b67c90e 100644 --- a/specifications/xslt-xquery-serialization-40/src/bibl.xml +++ b/specifications/xslt-xquery-serialization-40/src/bibl.xml @@ -63,6 +63,12 @@ Unicode Consortium. Unicode Standard Annex #15. + +JSON Lines. +Maintained by Ian Ward. + + diff --git a/specifications/xslt-xquery-serialization-40/src/schema-for-serialization-parameters.xsd b/specifications/xslt-xquery-serialization-40/src/schema-for-serialization-parameters.xsd index 5f2b09318..53b7b04c7 100644 --- a/specifications/xslt-xquery-serialization-40/src/schema-for-serialization-parameters.xsd +++ b/specifications/xslt-xquery-serialization-40/src/schema-for-serialization-parameters.xsd @@ -131,6 +131,16 @@ + + + diff --git a/specifications/xslt-xquery-serialization-40/src/xslt-xquery-serialization.xml b/specifications/xslt-xquery-serialization-40/src/xslt-xquery-serialization.xml index 571be7ca4..33a05d709 100644 --- a/specifications/xslt-xquery-serialization-40/src/xslt-xquery-serialization.xml +++ b/specifications/xslt-xquery-serialization-40/src/xslt-xquery-serialization.xml @@ -646,6 +646,9 @@ nodes.

Added the escape-solidus parameter for JSON serialization. + + Added the json-lines parameter for JSON serialization. +

There are a number of parameters that influence how serialization is performed. Host languages MAY allow users to specify any or all of these parameters, but @@ -728,6 +731,10 @@ This parameter MAY be absent. item-separatorA string of Unicode characters. This parameter MAY be absent. +json-linesOne of the enumerated values +yes, no, true, false, 1 or 0. + + json-node-output-method An expanded QName @@ -3400,14 +3407,32 @@ is described in .

Added the escape-solidus parameter for JSON serialization. + + Added the json-lines parameter for JSON serialization. + -

The JSON output method serializes the as -a JSON value using the JSON syntax defined in . -Sequence normalization is not performed for this output method. -

- +

The JSON output method serializes the + using the JSON syntax defined in . + Sequence normalization is not performed for this output method. + A list with values to be serialized is created from the , + depending on the value of the json-lines parameter:

+ + + +

If the value is one of yes, true or 1, + each item of the input value becomes a separate list entry. +

+
+ +

For all other values, the input value becomes a single list entry.

+
+
+

The serialized entries of the list are separated by the character U+000A. + The entries are serialized as follows:

+ +

An array item in the is serialized to a JSON array by outputting the serialized JSON value of @@ -3603,16 +3628,14 @@ one of the values yes, true or 1, the serializer MAY output additional whitespace characters adjacent to the JSON structural -tokens. If the indent parameter has the value -no, false or 0, -the serializer +tokens. For all other values, the serializer MUST output no whitespace characters adjacent to the JSON structural tokens.

-

-The suppress-indentation parameter is not applicable to -the JSON output method. -

+

If json-lines has one of the values yes, true or +1, indentation is allowed, but the output whitespace characters may not contain +the character U+000A.

+ @@ -3663,17 +3686,6 @@ the byte-order mark).

element, since an unintended </script> end tag might otherwise cause the script to be prematurely terminated. In other situations, however, the escaping creates visual clutter and makes the output less readable.

- - - - - -JSON Output Method: the item-separator Parameter - -

The item-separator serialization -parameter is not applicable to the JSON output method.

-
- JSON Output Method: the allow-duplicate-names Parameter

The allow-duplicate-names serialization parameter @@ -3702,6 +3714,13 @@ set to yes.

+ +JSON Output Method: the json-lines Parameter +

The json-lines serialization parameter determines if items are serialized +according to the format and as described in . +

+
+ @@ -4006,7 +4025,6 @@ adjacent serialized items. -