jsonpath-001

Tests a JSONPath definite query.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" name="main" version="3.0"
                expand-text="false">
   <p:import href="https://xmlcalabash.com/ext/library/jsonpath.xpl"/>
   <p:output port="result"/>
   <cx:jsonpath query="$.store.book[1].author">
      <p:with-input href="../documents/find/bookstore.json"/>
   </cx:jsonpath>
   <p:cast-content-type content-type="application/xml"/>
</p:declare-step>

Result

<string xmlns="http://www.w3.org/2005/xpath-functions"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">Evelyn Waugh</string>

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:string">The root is not a string.</s:assert>
         <s:assert test="fn:string = 'Evelyn Waugh'">The author is incorrect.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

11 May 2025, Norm Tovey-Walsh
Created test.