Try/catch 005

Test try-catch-005.xml is expected to pass.

The pipeline


<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions" xmlns:p="http://www.w3.org/ns/xproc" name="main" version="3.0">
                <!-- we should replace cx with something better -->
   <p:option name="error"/>
   <p:output port="result">
      <p:pipe step="try" port="finally"/>
   </p:output>
   <p:try name="try">
      <p:group>
         <p:choose>
            <p:when test="$error = 0">
               <p:identity>
                  <p:with-input port="source">
                     <p:inline>
                        <doc>try succeeded</doc>
                     </p:inline>
                  </p:with-input>
               </p:identity>
            </p:when>
            <p:when test="$error = 1">
               <p:error code="cx:error">
                  <p:with-input port="source">
                     <p:empty/>
                  </p:with-input>
               </p:error>
            </p:when>
            <p:otherwise>
               <p:error code="cx:error2">
                  <p:with-input port="source">
                     <p:empty/>
                  </p:with-input>
               </p:error>
            </p:otherwise>
         </p:choose>
      </p:group>
      <p:catch code="cx:error">
         <p:identity>
            <p:with-input port="source">
               <p:inline>
                  <doc>caught cx:error</doc>
               </p:inline>
            </p:with-input>
         </p:identity>
      </p:catch>
      <p:catch>
         <p:identity>
            <p:with-input port="source">
               <p:inline>
                  <doc>caught any</doc>
               </p:inline>
            </p:with-input>
         </p:identity>
      </p:catch>
      <p:finally>
         <p:output port="finally" primary="false">
            <p:pipe step="fident" port="result"/>
         </p:output>
         <p:identity name="fident">
            <p:with-input port="source">
               <p:inline>
                  <doc>finally</doc>
               </p:inline>
            </p:with-input>
         </p:identity>
      </p:finally>
   </p:try>
</p:declare-step>
MorganaXProc passing XML Calabash passing

Options

$error

select = 1

Schematron validation


<s:schema xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <s:ns prefix="c" uri="http://www.w3.org/ns/xproc-step"/>
   <s:pattern>
      <s:rule context="/*">
         <s:assert test="self::doc">The pipeline root is not doc.</s:assert>
         <s:assert test=". = 'finally'">The result isn't "finally"</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

10 Jun 2021, Achim Berndzen

Added attribute 'queryBinding' to schematron's schema.

24 Sep 2017 17:47, Norman Walsh

Port my test suite; add documentation and schemas