assertions-010

Tests a pipeline assertion against a binary document.

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:s="http://purl.oclc.org/dsdl/schematron"
                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:load name="load"
           href="../documents/documents.zip"
           cx:assertions="map { 'result': 'zip-has-mimetype' }"/>
   <cx:pipeline-messages p:depends="load" level="info"/>
   <p:pipeinfo cx:href="../documents/assertions.xml"/>
</p:declare-step>

Result

<cx:messages xmlns:cx="http://xmlcalabash.com/ns/extensions"
             xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <cx:message date="2025-06-19T18:02:13X" level="WARN"
               message="Assert cx:failed-assertion on p:load[load]/result: Mimetype file is missing from ZIP"/>
</cx:messages>

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="cx:messages">The document root is not correct.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/cx:messages">
         <s:assert test="cx:message[@level='WARN'                           and contains(@message, 'Mimetype file is missing from ZIP')]">Test did not detect error</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

02 Jan 2025, Norm Tovey-Walsh
Created test.