message-007

Tests that message on a step inside p:catch works.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:c="http://www.w3.org/ns/xproc-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>
      <p:with-input>
         <doc/>
      </p:with-input>
   </p:identity>
   <p:try name="dep">
      <p:output port="result"/>
      
      <p:error code="Q{}bang"/>
      <p:catch>
         <p:output port="result"/>
         <p:identity message="Element is {node-name(/*)}"/>
      </p:catch>
   </p:try>
   <cx:pipeline-messages name="messages"
                         p:depends="dep" level="info"/>
   <p:wrap-sequence wrapper="wrapper">
      <p:with-input pipe="result@dep result@messages"/>
   </p:wrap-sequence>
</p:declare-step>

Result

<wrapper xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <c:errors xmlns:c="http://www.w3.org/ns/xproc-step"
             xmlns:cx="http://xmlcalabash.com/ns/extensions"
             xmlns:err="http://www.w3.org/ns/xproc-error"
             xmlns:fnerr="http://www.w3.org/2005/xqt-errors">
      <c:error name="!expression_IC323722"
               type="cx:expression" code="err:XS0107"
               href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/message-007.xml" line="47" column="34">
         <cx:message>Static error in expression: Q{}bang</cx:message>
         <cx:explanation>It is a static error in XProc if any XPath expression or the XSLT selection 
pattern in option match on p:viewport contains a static error (error 
in expression syntax, references to unknown variables or functions, 
etc.).</cx:explanation>
         <cx:cause>lexical analysis failed</cx:cause>
         <cx:stack-trace>
            <cx:stack-frame type="cx:expression"
                            name="!expression_IC323722"/>
         </cx:stack-trace>
      </c:error>
   </c:errors>
   <cx:messages xmlns:cx="http://xmlcalabash.com/ns/extensions">
      <cx:message date="2026-03-03T14:56:34+00:00"
                  level="WARN"
                  message="Invalid value template expression: : lexical analysis failed"/>
      <cx:message date="2026-03-03T14:56:34+00:00"
                  level="INFO" message="Element is c:errors"/>
   </cx:messages>
</wrapper>

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:ns prefix="c"
         uri="http://www.w3.org/ns/xproc-step"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="wrapper">The document root is not correct.</s:assert>
         <s:assert test="wrapper/c:errors">No errors element</s:assert>
         <s:assert test="wrapper/cx:messages">No messages element</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="wrapper/cx:messages">
         <s:assert test="cx:message[@level='INFO' and contains(@message, 'Element is c:errors')]">No message output.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="wrapper/c:errors/c:error">
         <s:assert test="@code = 'err:XS0107'">Error code is wrong</s:assert>
         <s:assert test="cx:cause = 'lexical analysis failed'">Error reason is wrong</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

31 Jan 2026, Norm Tovey-Walsh
Corrected the test; it wasn’t testing what it thought it was testing.
24 Aug 2025, Norm Tovey-Walsh
Created test.