JSON merge 014(AB)

Joining map and JSON string with conflict in keys, explicit strategy combine.

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"
                xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0"
                exclude-inline-prefixes="xs">
   <p:output port="result"/>
   <p:json-merge key="'key1'" duplicates="combine">
      <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:variable name="seq" as="xs:string+" select=".?key1"/>
   <p:identity>
      <p:with-input>
         <result>
            <value1>{$seq[1]}</value1>
            <value2>{$seq[2]}</value2>
         </result>
      </p:with-input>
   </p:identity>
</p:declare-step>

Result

<result xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <value1>value</value1>
   <value2>one</value2>
</result>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="result">The document node is not 'result'.</s:assert>
         <s:assert test="result/value1 = 'value'">First value is not 'value'.</s:assert>
         <s:assert test="result/value2 = 'one'">Second value is not '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