<?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">
  <t:title>Test step-available #004</t:title>
  
  <t:description xmlns="http://www.w3.org/1999/xhtml">
    <p>Test that "forward references" to step types are
    handled correctly in <code>p:step-available</code>.</p>
  </t:description>
  
  <t:pipeline>
    <p:declare-step version='1.0' xmlns:ex="http://example.com/ns/xproc-extensions">
      <p:output port="result"/>

      <p:declare-step type="ex:user-defined1">
	<p:output port="result"/>

        <p:choose>
          <p:when test="p:step-available('ex:user-defined2')">
            <p:xpath-context>
              <p:empty/>
            </p:xpath-context>
            <p:identity>
              <p:input port="source">
                <p:inline>
                  <doc>Success.</doc>
                </p:inline>
              </p:input>
            </p:identity>
          </p:when>
          <p:otherwise>
            <p:identity>
              <p:input port="source">
                <p:inline>
                  <doc>Failure.</doc>
                </p:inline>
              </p:input>
            </p:identity>
          </p:otherwise>
        </p:choose>
      </p:declare-step>

      <p:declare-step type="ex:user-defined2">
	<p:input port="source"/>
	<p:output port="result"/>
	<p:identity/>
      </p:declare-step>

      <ex:user-defined1/>

    </p:declare-step>
  </t:pipeline>
  
  <t:output port="result">
    <doc>Success.</doc>
  </t:output>
</t:test>

