<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
  <t:info>
    <t:title>fileset-056</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2025-06-13</t:date>
        <t:author>
          <t:name>Norm Tovey-Walsh</t:name>
        </t:author>
        <t:description xmlns="http://www.w3.org/1999/xhtml">
          <p>Created test.</p>
        </t:description>
      </t:revision>
    </t:revision-history>
  </t:info>
  <t:description xmlns="http://www.w3.org/1999/xhtml">
    <p>Tests the first-match-mapper.</p>
  </t:description>

   <t:file-environment src="../documents/fileset-environment.xml"/>

  <t:pipeline>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:cx="http://xmlcalabash.com/ns/extensions"
                name="main" version="3.0">
  <p:import href="https://xmlcalabash.com/ext/library/fileset.xpl"/>
  <p:output port="result" sequence="true"/>

  <cx:fileset path="../testfolder/glob/a">
    <p:with-input>
      <fileset>
        <present target-dir="../testfolder/glob/b" present="both">
          <glob-mapper from="*.TXT" to="*.out"/>
        </present>
      </fileset>
    </p:with-input>
  </cx:fileset>
</p:declare-step>
  </t:pipeline>
  <t:schematron>
    <s:schema queryBinding="xslt2"
              xmlns:s="http://purl.oclc.org/dsdl/schematron">
      <s:ns prefix="c" uri="http://www.w3.org/ns/xproc-step"/>
      <s:pattern>
        <s:rule context="/">
          <s:assert test="c:directory">The root is wrong.</s:assert>
        </s:rule>
      </s:pattern>
      <s:pattern>
        <s:rule context="/c:directory">
          <s:assert test="ends-with(@xml:base, '/glob/a/')">The base URI is wrong.</s:assert>
          <s:assert test="count(c:directory) = 0">The number of directories is wrong.</s:assert>
          <s:assert test="count(c:file) = 0">The number of files is wrong.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  </t:schematron>
</t:test>
