Problems re-trowing exceptions in Calabash

Hello,

I have a case where I wish to catch exceptions raised by an XSLT transform that prematurely stops due to a terminate="yes" message. I can quite happily catch that exception with a p:try step. However, if I then want to throw a new exception that passes the original error info, along with some additional context info, up to the next level I lose that error info. When I run the example below in Calabash (9.1.5) I just get an empty c:errors element in my result. It seems that either by taking the result of the previous p:insert step as the input to the p:error step, or declaring a message in-line, in both cases I do not get the expected c:error message in my result.


<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step 
    xmlns:c="http://www.w3.org/ns/xproc-step"
    xmlns:ex="http://www.example.com/"
    xmlns:p="http://www.w3.org/ns/xproc"
    exclude-inline-prefixes="c p"
    name="rethrow-test"
    xpath-version="2.0">
  
  <p:input port="source" primary="true">
    <p:inline exclude-inline-prefixes="c p">
      <business id="B10000000">
        <name>Foo</name>
      </business>
    </p:inline>
  </p:input>
  <p:output port="result" primary="true"/>
  
  <p:serialization port="result" encoding="utf-8" indent="true" 
      media-type="application/xml" method="xml" omit-xml-declaration="false"/>
  
  <p:declare-step name="transform" type="ex:transform">
    <p:input port="source" primary="true"/>
    <p:output port="result" primary="true"/>
    
    <p:try>
      <p:group>
        <p:xslt name="exception">
          <p:input port="stylesheet">
            <p:inline>
              <xsl:transform 
                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  exclude-result-prefixes="xs"
                  version="2.0">
                
                <xsl:output encoding="UTF-8" indent="yes" media-type="application/xml" method="xml"/>
                
                <xsl:template match="/">
                  <xsl:message terminate="yes">[XSLT] Transform failed!</xsl:message>
                  <xsl:copy-of select="*"/>
                </xsl:template>
              </xsl:transform>
            </p:inline>
          </p:input>
          <p:input port="parameters">
            <p:empty/>
          </p:input>
        </p:xslt>
      </p:group>
      <p:catch name="catch1">
        <p:insert match="c:errors" position="last-child">
          <p:input port="source">
            <p:pipe port="error" step="catch1"/>
          </p:input>
          <p:input port="insertion">
            <p:inline exclude-inline-prefixes="c ex p">
              <c:error>[XProc] ex:transform failed.</c:error>
            </p:inline>
          </p:input>
        </p:insert>
        <p:error code="ex:TX001">
          <p:input port="source"><p:inline exclude-inline-prefixes="c ex p">
            <c:error>[XProc] Step ex:transform failed.</c:error>
          </p:inline>
          </p:input>
        </p:error>
      </p:catch>
    </p:try>
  </p:declare-step>
  
  <p:try>
    <p:group>
      <ex:transform/>
    </p:group>
    <p:catch name="catch2">
      <p:identity>
        <p:input port="source">
          <p:pipe port="error" step="catch2"/>
        </p:input>
      </p:identity>
    </p:catch>
  </p:try>
  
  <p:wrap-sequence wrapper="test"/>
</p:declare-step>



Regards

Philip Fennell
Consultant

Mark Logic Corporation
www.marklogic.com

E-mail: philip.fennell@marklogic.com
Mobile: +44 (0)7824 830 866 

Received on Wednesday, 2 December 2009 11:45:01 UTC