Tests that the cache is used for XPath expressions.
Test compile-cache-004.xml is expected to pass.
<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" version="3.0">
<p:import href="https://xmlcalabash.com/ext/library/pipeline-messages.xpl"/>
<p:import href="https://xmlcalabash.com/ext/library/xpath.xpl"/>
<p:output port="result"/>
<p:declare-step type="ex:xpath">
<p:input port="source" primary="true"/>
<p:input port="xpath"/>
<p:output port="result" sequence="true"/>
<cx:xpath cx:cache-expression="true">
<p:with-input port="source" pipe="source"/>
<p:with-input port="xpath" pipe="xpath"/>
</cx:xpath>
</p:declare-step>
<ex:xpath>
<p:with-input port="source">
<doc/>
</p:with-input>
<p:with-input port="xpath" href="../documents/xpath.txt"/>
</ex:xpath>
<ex:xpath name="xpath">
<p:with-input port="source">
<doc>
<para>Testing</para>
</doc>
</p:with-input>
<p:with-input port="xpath" href="../documents/xpath.txt"/>
</ex:xpath>
<cx:pipeline-messages name="messages" p:depends="xpath" level="debug"/>
<p:wrap-sequence wrapper="wrapper">
<p:with-input pipe="@xpath @messages"/>
</p:wrap-sequence>
</p:declare-step>
<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" 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: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>
Created test.