try-catch-006

Tests that an error code in a namespace raised by an XSLT stylesheet is reflected correctly in the error 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:ex="http://example.com/ns/step"
                xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
   <p:output port="result"/>
   <p:try>
      <p:xslt>
         <p:with-input port="stylesheet"
                       href="../documents/xslt-dynamic-error-ns3.xsl"/>
         <p:with-input port="source"
                       href="../documents/xslt-dynamic-error-ns3.xsl"/>
      </p:xslt>
      <p:catch>
         <p:identity/>
      </p:catch>
   </p:try>
</p:declare-step>

Result

<c:errors xmlns:c="http://www.w3.org/ns/xproc-step"
          xmlns:cpfx="http://example.com/an/error/namespace"
          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" xmlns:p="http://www.w3.org/ns/xproc"
          xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <c:error name="!xslt" type="p:xslt" code="err:XC0096"
            href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/try-catch-006.xml" line="31" column="17" cause="cpfx:error-code">
      <cx:input-location href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/documents/xslt-dynamic-error-ns3.xsl"
                         line="7" column="99"/>
      <cx:message>Stylesheet terminated with xsl:message: “Error signalled by application call on error()”.</cx:message>
      <cx:explanation>It is a dynamic error if the transformation is terminated by XSLT message 
termination.</cx:explanation>
      <cx:cause>Error signalled by application call on error()</cx:cause>
      <cx:stack-trace>
         <cx:stack-frame type="p:xslt" name="!xslt"/>
         <cx:stack-frame type="p:group" name="!group"/>
      </cx:stack-trace>
   </c:error>
</c:errors>

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="c"
         uri="http://www.w3.org/ns/xproc-step"/>
   <s:ns prefix="cx"
         uri="http://xmlcalabash.com/ns/extensions"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="c:errors">The document is wrong</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/c:errors">
         <s:assert test="count(c:error) = 1">Wrong number of errors</s:assert>
         <s:assert test="c:error/@code = 'err:XC0096'">Wrong error code</s:assert>
         <s:assert test="c:error/@cause = 'cpfx:error-code'">Wrong error cause</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

20 Jul 2026, Norm Tovey-Walsh
Created test.