<?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"
	ignore-whitespace-differences="true">

<t:title>Test directory-list-001</t:title>

<t:description xmlns="http://www.w3.org/1999/xhtml">
  <p>To pass this test, it must be
  run in a location where there is a directory named
  “directory-list-test”. The directory must have the following structure:</p>
  <pre>    afile
    bfile
    adir/
    adir/cfile
    bdir/</pre>
  <p>The directory “bdir” must not be accessible for reading.</p>
</t:description>

<t:option name="path" value="directory-list-test"/>

<t:pipeline>
<p:declare-step version='1.0' xmlns:p="http://www.w3.org/ns/xproc"
		xmlns:px="http://example.org/ns/pipelines"
		xmlns:c="http://www.w3.org/ns/xproc-step"
		name="main">
<p:output port="result"/>
<p:option name="path" required="true"/>

<p:directory-list name="dirlist">
  <p:with-option name="path" select="$path">
    <p:empty/>
  </p:with-option>
</p:directory-list>

<p:identity name="testadir">
  <p:input port="source" select="/c:directory/c:directory[@name='adir']">
    <p:pipe step="dirlist" port="result"/>
  </p:input>
</p:identity>

<p:identity name="testbdir">
  <p:input port="source" select="/c:directory/c:directory[@name='bdir']">
    <p:pipe step="dirlist" port="result"/>
  </p:input>
</p:identity>

<p:identity name="testafile">
  <p:input port="source" select="/c:directory/c:file[@name='afile']">
    <p:pipe step="dirlist" port="result"/>
  </p:input>
</p:identity>

<p:identity name="testbfile">
  <p:input port="source" select="/c:directory/c:file[@name='bfile']">
    <p:pipe step="dirlist" port="result"/>
  </p:input>
</p:identity>

<p:identity name="testcfile">
  <p:input port="source" select="/c:directory//c:file[@name='cfile']">
    <p:pipe step="dirlist" port="result"/>
  </p:input>
</p:identity>

<p:count>
  <p:input port="source">
    <p:pipe step="testadir" port="result"/>
    <p:pipe step="testbdir" port="result"/>
    <p:pipe step="testafile" port="result"/>
    <p:pipe step="testbfile" port="result"/>
    <p:pipe step="testcfile" port="result"/>
  </p:input>
</p:count>

</p:declare-step>
</t:pipeline>

<t:output port='result'><c:result>4</c:result></t:output>

</t:test>
