JSON merge 019(AB)

Tests mixing all possible documents

Test ab-json-merge-019.xml is expected to pass.

The pipeline


<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
   <p:output port="result"/>
   <p:json-merge key="concat('label-',$p:index)">
      <p:with-input expand-text="false">
         <p:inline content-type="application/json">{"key1" : "value1"}</p:inline>
         <p:inline content-type="application/json">[1, 2]</p:inline>
         <p:inline content-type="text/plain">This is a text document.</p:inline>
         <p:inline>
            <xml/>
         </p:inline>
         <p:inline content-type="text/html">
            <html/>
         </p:inline>
      </p:with-input>
   </p:json-merge>
   <p:cast-content-type content-type="application/xml"/>
</p:declare-step>
MorganaXProc passing XML Calabash passing

Schematron validation


<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" 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="count(fn:map/*)=5">Document does not have five children.</s:assert>
      </s:rule>
      <s:rule context="/fn:map/*[1]">
         <s:assert test="local-name(.)='string'">Local name of child element 1 is not 'string'.</s:assert>
         <s:assert test="./@key='key1'">Child element 1 does not have @key with 'key1'.</s:assert>
         <s:assert test="./text()='value1'">Child element 1 does not have text child 'value1'.</s:assert>
      </s:rule>
      <s:rule context="/fn:map/*[2]">
         <s:assert test="local-name(.)='array'">Local name of child element 2 is not 'array'.</s:assert>
         <s:assert test="./@key='label-2'">Child element 2 does not have @key with 'label-2'.</s:assert>
         <s:assert test="./fn:number[1]='1'">Child element 2 does not have a child 'fn:number' with '1'.</s:assert>
         <s:assert test="./fn:number[2]='2'">Child element 2 does not have a child 'fn:number' with '2'.</s:assert>
      </s:rule>
      <s:rule context="/fn:map/*[3]">
         <s:assert test="local-name(.)='string'">Local name of child element 3 is not 'string'.</s:assert>
         <s:assert test="./@key='label-3'">Child element 3 does not have @key with 'label-3'.</s:assert>
         <s:assert test="./text()='This is a text document.'">Child element 3 does not have text child with 'This is a text document'.</s:assert>
      </s:rule>
      <s:rule context="/fn:map/*[4]">
         <s:assert test="local-name(.)='string'">Local name of child element 4 is not 'string'.</s:assert>
         <s:assert test="./@key='label-4'">Child element 4 does not have @key with 'label-4'.</s:assert>
         <s:assert test="./text()='&lt;xml/&gt;'">Child element 4 does not have text child with '&lt;xml/&gt;'.</s:assert>
      </s:rule>
      <s:rule context="/fn:map/*[5]">
         <s:assert test="local-name(.)='string'">Local name of child element 5 is not 'string'.</s:assert>
         <s:assert test="./@key='label-5'">Child element 5 does not have @key with 'label-5'.</s:assert>
         <s:assert test="starts-with(./text(), '&lt;html')">Child element 5 does not have text child with '&lt;html/&gt;'.</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