<?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 variable #004</t:title>
  
  <t:description xmlns="http://www.w3.org/1999/xhtml">
    <p>Tests that bindings for all preceding-sibling p:variable
    and p:option elements are available in the select expression
    of p:variable.</p>
  </t:description>
  
  <t:input port="source">
    <doc>
      <para>some para</para>
      <para>some para</para>
    </doc>
  </t:input>

  <t:pipeline>
    
    <p:declare-step version='1.0' name="main">
      <p:input port="source"/>
      <p:output port="result"/>
      <p:option name="opt" select="'val'"/>
      <p:variable name="var1" select="concat($opt, 'foo')"/>
      <p:variable name="var2" select="concat($var1, 'bar')"/>

      <p:choose>
        <p:when test="$opt = 'val' and $var1 = 'valfoo' and $var2 = 'valfoobar'">
          <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:declare-step>

  </t:pipeline>

  <t:output port="result">
    <success/>
  </t:output>

</t:test>
