<?xml-stylesheet type="text/xsl" href="/style/testcase.xsl"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite"
      xmlns:p="http://www.w3.org/ns/xproc"
      xmlns:c="http://www.w3.org/ns/xproc-step"
      xmlns:err="http://www.w3.org/ns/xproc-error"
      xmlns:usrerr="http://xproc.org/ns/user-error">
  <t:title>Test p:error #003</t:title>

  <t:description xmlns="http://www.w3.org/1999/xhtml">                                                              
    <p>Tests code-namespace and code-prefix.</p>
  </t:description>     

  <t:pipeline>
    <p:declare-step version='1.0'>
      <p:output port="result"/>
      <p:try>
        <p:group>
          <p:error code="error" code-namespace="http://baz.com" code-prefix="baz">
            <p:input port="source">
              <p:inline>
                <message>Bang!</message>
              </p:inline>
            </p:input>
          </p:error>
          <p:sink/>
          <p:identity>
            <p:input port="source">
              <p:inline>
                <failure-no-error/>
              </p:inline>
            </p:input>
          </p:identity>
        </p:group>
        <p:catch name="catch">
          <p:choose>
            <p:xpath-context>
              <p:pipe step="catch" port="error"/>
            </p:xpath-context>
            <p:when test="//c:error[@code='baz:error'] and //c:error[namespace::baz='http://baz.com']">
              <p:identity>
                <p:input port="source">
                  <p:inline>
                    <success/>
                  </p:inline>
                </p:input>
              </p:identity>
            </p:when>
            <p:otherwise>
              <p:identity>
                <p:input port="source">
                  <p:inline>
                    <failure/>
                  </p:inline>
                </p:input>
              </p:identity>
            </p:otherwise>
          </p:choose>
        </p:catch>
      </p:try>
    </p:declare-step>
  </t:pipeline>
  
  <t:output port="result">
    <success/>
  </t:output>
  
</t:test>


