JSON merge 023(AB)
Tests that the string value of a node result is taken as key.
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-merge key="concat('label-',.)">
<p:with-input>
<p:inline>
<doc>1</doc>
</p:inline>
<p:inline>
<doc>2</doc>
</p:inline>
</p:with-input>
</p:json-merge>
<p:cast-content-type content-type="application/xml"/>
</p:declare-step>
Result
<map xmlns="http://www.w3.org/2005/xpath-functions"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<string key="label-1"><doc>1</doc></string>
<string key="label-2"><doc>2</doc></string>
</map>
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="fn"
uri="http://www.w3.org/2005/xpath-functions"/>
<s:pattern>
<s:rule context="/">
<s:assert test="fn:map">The document node is not 'fn:map'.</s:assert>
<s:assert test="fn:map/fn:string/@key='label-1'">No element with @key = 'label-1' found.</s:assert>
<s:assert test="fn:map/fn:string/@key='label-2'">No element with @key = 'label-2' found.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 10 Jun 2021, Achim Berndzen
- Added attribute 'queryBinding' to schematron's schema.
- 13 Oct 2019, Achim Berndzen
- Added tests for p:json-merge