JSON merge 013(AB)

Joining map and JSON string with conflict in keys, explicit strategy use-any.

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="'key1'" duplicates="use-any">
      <p:with-input expand-text="false">
         <p:inline content-type="application/json">{"key1" : "value"}</p:inline>
         <p:inline content-type="application/json">"one"</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="key1">value</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="map"
         uri="http://www.w3.org/2005/xpath-functions"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="map:map">The document node is not 'map:map'.</s:assert>
         <s:assert test="count(map:map/*)=1">Element 'map:map' does not have one child.</s:assert>
         <s:assert test="count(map:map/map:string)=1">Element 'map:map' does not have one child 'map:string'.</s:assert>
         <s:assert test="map:map/map:string[@key='key1'] = 'value' or                                map:map/map:string[@key='key1'] = 'one'">Value of string/@key='key1' is neither 'value' nor 'one'.</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