Skip to content

Commit

Permalink
JSON Serialization: json-lines. Closes qt4cg#1471 (qt4cg#1497)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianGruen authored Oct 29, 2024
1 parent a519271 commit c58b5b8
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 24 deletions.
12 changes: 12 additions & 0 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19119,6 +19119,18 @@ return tokenize(normalize-space($s), ' ')[. castable as xs:IDREF]</eg>
<td/>
<td>absent</td>
</tr>
<tr>
<td>
<code>json-lines</code>
</td>
<td>
<code>xs:boolean?</code>
</td>
<td><code>true()</code> means <code>"yes"</code>, <code>false()</code> means <code>"no"</code></td>
<td>
<code>no</code>
</td>
</tr>
<tr>
<td>
<code>json-node-output-method</code>
Expand Down
6 changes: 6 additions & 0 deletions specifications/xslt-xquery-serialization-40/src/bibl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ Unicode Consortium.
Unicode Standard Annex #15.
</bibl>

<bibl id="JSON-LINES"
key="JSON Lines">
<titleref href="https://jsonlines.org/">JSON Lines</titleref>.
Maintained by Ian Ward.
</bibl>

<bibl id="xhtml1" key="XHTML 1.0"/>

<bibl id="xhtml11" key="XHTML 1.1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@
</xs:union>
</xs:simpleType>

<!--
- Serialization parameter element for json-lines
parameter
-->
<xs:element id="json-lines"
name="json-linestype"
type="output:yes-no-param-type"
substitutionGroup
= "output:serialization-parameter-element"/>

<xs:simpleType name="method-type">
<xs:union>
<xs:simpleType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,9 @@ nodes.</p></note></div1>
<change issue="530" PR="534" date="2023-06-06">
Added the <code>escape-solidus</code> parameter for JSON serialization.
</change>
<change issue="1471" date="2024-10-15">
Added the <code>json-lines</code> parameter for JSON serialization.
</change>
</changes>
<p>There are a number of parameters that influence how serialization
is performed. <termref def="host-language">Host languages</termref> <rfc2119>MAY</rfc2119> allow users to specify any or all of these parameters, but
Expand Down Expand Up @@ -728,6 +731,10 @@ This parameter <rfc2119>MAY</rfc2119> be absent.</td>
<tr><td rowspan="1" colspan="1"><code>item-separator</code></td><td rowspan="1" colspan="1">A string of Unicode characters. This
parameter <rfc2119>MAY</rfc2119> be absent.</td></tr>

<tr><td rowspan="1" colspan="1"><code>json-lines</code></td><td rowspan="1" colspan="1">One of the enumerated values
<code>yes</code>, <code>no</code>, <code>true</code>, <code>false</code>, <code>1</code> or <code>0</code>.
</td></tr>

<tr>
<td rowspan="1" colspan="1"><code>json-node-output-method</code></td>
<td rowspan="1" colspan="1">An expanded QName
Expand Down Expand Up @@ -3400,14 +3407,32 @@ is described in <specref ref="serdm"/>.</p>
<change issue="530" PR="534" date="2023-06-06">
Added the <code>escape-solidus</code> parameter for JSON serialization.
</change>
<change issue="1471" date="2024-10-15">
Added the <code>json-lines</code> parameter for JSON serialization.
</change>
</changes>

<p>The JSON output method serializes the <termref diff="chg" at="2023-11-01" def="dt-input-tree"/> as
a JSON value using the JSON syntax defined in <bibref ref="rfc7159"/>.
Sequence normalization is not performed for this output method.
</p>
<ulist>
<p>The JSON output method serializes the <termref diff="chg" at="2023-11-01" def="dt-input-tree"/>
using the JSON syntax defined in <bibref ref="rfc7159"/>.
Sequence normalization is not performed for this output method.
A list with values to be serialized is created from the <termref def="dt-input-value"/>,
depending on the value of the <code>json-lines</code> parameter:</p>

<ulist>
<item>
<p>If the value is one of <code>yes</code>, <code>true</code> or <code>1</code>,
each item of the input value becomes a separate list entry.
</p>
</item>
<item>
<p>For all other values, the input value becomes a single list entry.</p>
</item>
</ulist>

<p>The serialized entries of the list are separated by the character <char>U+000A</char>.
The entries are serialized as follows:</p>

<ulist>
<item><p>An <termref def="dt-array-item">array item</termref> in the
<termref diff="chg" at="2023-11-01" def="dt-input-tree"/> is
serialized to a JSON array by outputting the serialized JSON value of
Expand Down Expand Up @@ -3603,16 +3628,14 @@ one of the values <code>yes</code>, <code>true</code> or <code>1</code>,
the <termref
def="serializer">serializer</termref> <rfc2119>MAY</rfc2119> output
additional whitespace characters adjacent to the JSON structural
tokens. If the <code>indent</code> parameter has the value
<code>no</code>, <code>false</code> or <code>0</code>,
the <termref def="serializer">serializer</termref>
tokens. For all other values, the <termref def="serializer">serializer</termref>
<rfc2119>MUST</rfc2119> output no whitespace characters adjacent to
the JSON structural tokens.
</p>
<p>
The <code>suppress-indentation</code> parameter is not applicable to
the JSON output method.
</p>
<p>If <code>json-lines</code> has one of the values <code>yes</code>, <code>true</code> or
<code>1</code>, indentation is allowed, but the output whitespace characters may not contain
the character <char>U+000A</char>.</p>

</div3>


Expand Down Expand Up @@ -3663,17 +3686,6 @@ the byte-order mark).</p>
element, since an unintended <code>&lt;/script></code> 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.</p></note></div3>





<div3 id="JSON_ITEM-SEPARATOR">
<head>JSON Output Method: the <code>item-separator</code> Parameter</head>

<p>The <code>item-separator</code> serialization
parameter is not applicable to the JSON output method.</p>
</div3>

<div3 id="JSON_ALLOW-DUPLICATE-NAMES">
<head>JSON Output Method: the <code>allow-duplicate-names</code> Parameter</head>
<p>The <code>allow-duplicate-names</code> serialization parameter
Expand Down Expand Up @@ -3702,6 +3714,13 @@ set to <code>yes</code>.
</p>
</div3>

<div3 id="JSON_JSON-LINES">
<head>JSON Output Method: the <code>json-lines</code> Parameter</head>
<p>The <code>json-lines</code> serialization parameter determines if items are serialized
according to the <bibref ref="JSON-LINES"/> format and as described in <specref ref="json-output"/>.
</p>
</div3>

</div2>
</div1>

Expand Down Expand Up @@ -4006,7 +4025,6 @@ adjacent serialized items.
</div3>



</div2>
</div1>

Expand Down

0 comments on commit c58b5b8

Please sign in to comment.