<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/assertions-004.xml"
        name="assertions-004.xml"
        expected="pass">
   <t:info>
      <t:title>assertions-004</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2024-12-27</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Created test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests a Schematron assertion.</p>
   </t:description>
   <t:input port="source">
      <not-doc/>
   </t:input>
   <t: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"
                      version="3.0">
         <p:import href="https://xmlcalabash.com/ext/library/pipeline-messages.xpl"/>
         <p:input port="source" cx:assertions="'input-correct'"/>
         <p:output port="result" cx:assertions="'output-correct'"/>
         <p:identity name="identity"/>
         <cx:pipeline-messages p:depends="identity" level="info" clear="true"/>
         <p:pipeinfo cx:href="../documents/assertions.xml"/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <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="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, 'The source document is not a doc')]">Did not find Schematron report for doc.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="assertions-004.xml">
      <cx:messages xmlns:cx="http://xmlcalabash.com/ns/extensions">
         <cx:message date="2026-06-15T18:46:09+00:00"
                     level="WARN"
                     message="Assert on p:declare-step/source: The source document is not a doc"/>
      </cx:messages>
   </t:result>
</t:test>
