JSON join 004(AB)
Tests simple p:JSON-join with mixed entries: 'flatten-to-depth' = 2
Test is expected to pass.
The pipeline
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
<p:output port="result"/>
<p:json-join flatten-to-depth="2">
<p:with-input>
<p:inline content-type="application/json">[ "A", 1]</p:inline>
<p:inline content-type="application/json">"B"</p:inline>
<p:inline content-type="application/json">[42, ["D", true]]</p:inline>
</p:with-input>
</p:json-join>
<p:cast-content-type content-type="application/xml"/>
</p:declare-step>
Result
<array xmlns="http://www.w3.org/2005/xpath-functions"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<string>A</string>
<number>1</number>
<string>B</string>
<number>42</number>
<string>D</string>
<boolean>true</boolean>
</array>
Schematron checks
<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
<s:ns prefix="xpath"
uri="http://www.w3.org/2005/xpath-functions"/>
<s:pattern>
<s:rule context="/">
<s:assert test="xpath:array">The document root is not 'array'.</s:assert>
<s:assert test="count(xpath:array/*) = 6">Root element does not have 6 children.</s:assert>
<s:assert test="xpath:array/*[1]/name()='string'">First child is not 'string'.</s:assert>
<s:assert test="xpath:array/*[2]/name()='number'">Second child is not 'number'.</s:assert>
<s:assert test="xpath:array/*[3]/name()='string'">Third child is not 'string'.</s:assert>
<s:assert test="xpath:array/*[4]/name()='number'">Forth child is not 'number'.</s:assert>
<s:assert test="xpath:array/*[5]/name()='string'">Fifth child is not 'string'.</s:assert>
<s:assert test="xpath:array/*[6]/name()='boolean'">Sixth child is not 'boolean'.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 10 Jun 2021, Achim Berndzen
- Added attribute 'queryBinding' to schematron's schema.
- 06 Sep 2019, Achim Berndzen
- Added tests for p:json-join