cache-007

Tests that the same URI with different content types can be cached.

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: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/cache.xpl"/>
   <p:output port="result"/>
   <cx:cache-add name="cache-add-1"
                 href="https://xmlcalabash.com/does/not/exist.xml">
      <p:with-input>
         <does-so/>
      </p:with-input>
   </cx:cache-add>
   <cx:cache-add name="cache-add-2"
                 href="https://xmlcalabash.com/does/not/exist.xml">
      <p:with-input>
         <p:inline content-type="text/plain"><actually-text></p:inline>
      </p:with-input>
   </cx:cache-add>
   <p:try>
      <p:xinclude depends="cache-add-1 cache-add-2">
         <p:with-input>
            <doc xmlns:xi="http://www.w3.org/2001/XInclude">
               <as-xml>
                  <xi:include href="https://xmlcalabash.com/does/not/exist.xml"/>
               </as-xml>
               <as-text>
                  <xi:include href="https://xmlcalabash.com/does/not/exist.xml"
                              parse="text"/>
               </as-text>
            </doc>
         </p:with-input>
      </p:xinclude>
      <p:catch code="err:XC0029">
         <p:identity>
            <p:with-input>
               <fail/>
            </p:with-input>
         </p:identity>
      </p:catch>
   </p:try>
</p:declare-step>

Result

<doc xmlns:cx="http://xmlcalabash.com/ns/extensions"
     xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:t="http://xproc.org/ns/testsuite/3.0"
     xmlns:xi="http://www.w3.org/2001/XInclude">
   <as-xml>
      <does-so/>
   </as-xml>
   <as-text><actually-text></as-text>
</doc>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="doc">The document root is not doc.</s:assert>
         <s:assert test="doc/as-xml/does-so">The document doesn’t contain does-so.</s:assert>
         <s:assert test="contains(doc/as-text, '<actually-text>')">The document doesn’t contain actually-text.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

16 Apr 2025, Norm Tovey-Walsh
Created test.