JSON join 010(AB)

Tests simple p:JSON-join with doc, text, and json entries.

Test ab-json-join-010.xml is expected to pass.

The pipeline


<p:declare-step xmlns:array="http://www.w3.org/2005/xpath-functions/array" xmlns:map="http://www.w3.org/2005/xpath-functions/map" xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
   <p:output port="result"/>
   <p:json-join>
      <p:with-input>
         <p:inline>
            <node/>
         </p:inline>
         <p:inline content-type="text/plain">This is a text.</p:inline>
         <p:inline content-type="application/json" expand-text="false">{"json" : "value"}</p:inline>
      </p:with-input>
   </p:json-join>
   <p:variable name="key" select="map:keys(array:get(., 3))[1]"/>
   <p:identity>
      <p:with-input>
         <result>
            <one>{array:get(.,1)}</one>
            <two>{array:get(.,2)}</two>
            <three key="{$key}">{map:get(array:get(., 3), $key)}</three>
         </result>
      </p:with-input>
   </p:identity>
</p:declare-step>
MorganaXProc passing XML Calabash passing

Schematron validation


<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="result">The document node is not 'result'.</s:assert>
         <s:assert test="result/one/node">Element 'one' does not have child 'node'.</s:assert>
         <s:assert test="result/two/text()='This is a text.'">Text child of element 'two' is not 'This is a text.'</s:assert>
         <s:assert test="result/three/@key='json'">Attribute 'key' of element 'three' is not 'json'.</s:assert>
         <s:assert test="result/three/text()='value'">Text child of element 'three' is not 'value'.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

10 Jun 2021, Achim Berndzen

Added attribute 'queryBinding' to schematron's schema.

07 Oct 2019, Achim Berndzen

Added tests for p:json-join