<?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 choose #005</t:title>

<t:description xmlns="http://www.w3.org/1999/xhtml">                                                              
  <p>Tests p:xpath-context usage within p:choose.</p>
</t:description>     

<t:input port='source'>
<document>
<title>Some Title</title>
<para>Some paragraph.</para>
</document>

</t:input>

<t:input port='alternate'>                                                                                           
<document>                                                                                                        
<para>Some alternate paragraph.</para>                                                                                      
</document>                                                                                                       
                                                                                                                  
</t:input>  

<t:pipeline>
<p:pipeline version='1.0' name="pipeline">
  <p:input port="alternate"/>

<p:choose>
  <p:when test="//para">
	<p:xpath-context>
	  <p:pipe step="pipeline" port="alternate"/>
	</p:xpath-context>
    <p:output port="result"/>
    <p:identity>
      <p:input port="source">
	<p:inline><p>Alternate input port contains a //para element.</p></p:inline>
      </p:input>
    </p:identity>
  </p:when>
  <p:when test="//title">                                                                                         
    <p:xpath-context>                                                                                             
      <p:pipe step="pipeline" port="source"/>                                                                  
    </p:xpath-context>                                                                                            
    <p:output port="result"/>                                                                                     
    <p:identity>                                                                                                  
      <p:input port="source">                                                                                     
    <p:inline><p>Source input port contains a //para element.</p></p:inline>                                  
      </p:input>                                                                                                  
    </p:identity>                                                                                                 
  </p:when>   
  <p:otherwise>
    <p:output port="result"/>
    <p:identity>
      <p:input port="source">
    <p:inline><p>no input contains a //para element.</p></p:inline>                                     
      </p:input>
    </p:identity>
  </p:otherwise>
</p:choose>

</p:pipeline>
</t:pipeline>

<t:output port='result'><p>Alternate input port contains a //para element.</p></t:output>

</t:test>


