jsonpath-002
Tests a JSONPath indefinite 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="$..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
<array xmlns="http://www.w3.org/2005/xpath-functions"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<string>Evelyn Waugh</string>
</array>
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:array">The root is not an array.</s:assert>
</s:rule>
<s:rule context="fn:array">
<s:assert test="count(*) = 1">Wrong number of results.</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.