Try/catch 003

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

The pipeline

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:cx="http://xmlcalabash.com/ns/extensions" name="main" version="3.0">
                
  <p:option name="error"/>
  <p:output port="result"/>

  <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 = 2

Schematron validation


      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron">
         <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=". = 'caught any'">The result isn't "caught any"</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   

Revision history

24 Sep 2017 17:47, Norman Walsh

Port my test suite; add documentation and schemas