assertions-008

Tests a Schematron assertion.

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:identity name="identity"
               cx:assertions="map { 'result': 'correct-map' }">
      <p:with-input select="map { 'now': current-dateTime(), 'count': 12 }">
         <irrelevant/>
      </p:with-input>
   </p:identity>
   <cx:pipeline-messages p:depends="identity"
                         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:12X" level="INFO"
               message="Report on p:identity[identity]/result: Test date: 2025-06-19T18:02:12.513513179Z"/>
</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:rule context="/cx:messages">
         <s:assert test="cx:message[@level='INFO' and contains(@message, 'Test date:')]">Test did not produce a test date</s:assert>
         <s:assert test="cx:message[@level='WARN' and contains(@message, 'Threshold exceeded:')]">Test did not detect threshold</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

28 Dec 2024, Norm Tovey-Walsh
Revised. Test can now pass because of implementation changes.
27 Dec 2024, Norm Tovey-Walsh
Created test.