compile-cache-005
Tests that the cache is used for Saxon XQuery expressions.
Test is expected to pass.
The pipeline
<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:ex="http://example.com/ns/step"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
<p:import href="https://xmlcalabash.com/ext/library/pipeline-messages.xpl"/>
<p:output port="result"/>
<p:declare-step type="ex:xquery">
<p:input port="source" primary="true"/>
<p:input port="query"/>
<p:output port="result" sequence="true"/>
<p:xquery cx:cache-query="true">
<p:with-input port="source" pipe="source"/>
<p:with-input port="query" pipe="query"/>
</p:xquery>
</p:declare-step>
<ex:xquery>
<p:with-input port="source">
<doc/>
</p:with-input>
<p:with-input port="query"
href="../documents/xpath.txt"/>
</ex:xquery>
<ex:xquery name="xquery" cx:cache-query="true">
<p:with-input port="source">
<doc>
<para>Testing</para>
</doc>
</p:with-input>
<p:with-input port="query"
href="../documents/xpath.txt"/>
</ex:xquery>
<cx:pipeline-messages name="messages"
p:depends="xquery" level="debug"/>
<p:wrap-sequence wrapper="wrapper">
<p:with-input pipe="@xquery @messages"/>
</p:wrap-sequence>
</p:declare-step>
Result
<wrapper xmlns:t="http://xproc.org/ns/testsuite/3.0">
<para xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:ex="http://example.com/ns/step">Testing</para>
<cx:messages xmlns:cx="http://xmlcalabash.com/ns/extensions">
<cx:message date="2026-03-08T19:35:03+00:00"
level="DEBUG"
message="Running with XQuery processor: https://saxonica.com/"/>
<cx:message date="2026-03-08T19:35:03+00:00"
level="DEBUG"
message="Caching compiled resource: !xquery_2|file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/documents/xpath.txt"/>
<cx:message date="2026-03-08T19:35:03+00:00"
level="DEBUG"
message="Running with XQuery processor: https://saxonica.com/"/>
<cx:message date="2026-03-08T19:35:03+00:00"
level="DEBUG"
message="Using cached resource: !xquery_2|file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/documents/xpath.txt"/>
</cx:messages>
</wrapper>
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="cx"
uri="http://xmlcalabash.com/ns/extensions"/>
<s:pattern>
<s:rule context="/">
<s:assert test="wrapper">The document root is not correct.</s:assert>
<s:assert test="wrapper/para">No para</s:assert>
<s:assert test="wrapper/cx:messages">No messages</s:assert>
</s:rule>
</s:pattern>
<s:pattern>
<s:rule context="wrapper/para">
<s:assert test=". = 'Testing'">The para is wrong</s:assert>
</s:rule>
</s:pattern>
<s:pattern>
<s:rule context="/wrapper/cx:messages">
<s:assert test="cx:message[@level='DEBUG' and matches(@message, 'Caching compiled.*documents/xpath\.txt')]">No caching message.</s:assert>
<s:assert test="cx:message[@level='DEBUG' and matches(@message, 'Using cached.*documents/xpath\.txt')]">No using cached message.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 21 Jan 2026, Norm Tovey-Walsh
- Created test.