<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="cmdline-003.xml"
        name="cmdline-003.xml"
        expected="pass">
   <t:info>
      <t:title>cmdline-003</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-02-22</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>Simple test of the command-line testing framework capturing non-XML.</p>
   </t:description>
   <t:pipeline arguments="--pipe --output:result=result.xml --output:image=doc.png                          --output:json=doc.json --output:text=doc.txt">
      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      version="3.0"
                      name="main">
         <p:output port="result" primary="true"/>
         <p:output port="image" pipe="@image"/>
         <p:output port="json" pipe="@json" serialization="map{'method':'json'}"/>
         <p:output port="text" pipe="@text" serialization="map{'method':'text'}"/>
         <p:load name="image" href="../documents/document.png"/>
         <p:load name="json" href="../documents/rdf.json"/>
         <p:load name="text" href="../documents/document.txt"/>
         <p:identity>
            <p:with-input>
               <doc>primary</doc>
            </p:with-input>
         </p:identity>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:pattern>
            <s:rule context="/">
               <s:assert test="directory">The root is wrong.</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory">
               <s:assert test="count(file) = 5">Incorrect number of file results</s:assert>
               <s:assert test="count(*) = count(file)">Non-file results</s:assert>
               <s:assert test="file[@uri='doc.png']">No image</s:assert>
               <s:assert test="file[@uri='result.xml']">No XML result</s:assert>
               <s:assert test="file[@uri='doc.txt']">No text</s:assert>
               <s:assert test="file[@uri='doc.json']">No JSON</s:assert>
               <s:assert test="file[@uri='_stdout']">No stdout</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory/file[@uri='doc.png']">
               <s:assert test="@size = 25441">Incorrect size</s:assert>
               <s:assert test="starts-with(., '89504E470D0A1A0')">Incorrect PNG content</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory/file[@uri='result.xml']">
               <s:assert test="doc = 'primary'">Incorrect XML content</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory/file[@uri='doc.txt']">
               <s:assert test="starts-with(., 'Hello, world.')">Incorrect text content</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory/file[@uri='doc.json']">
               <s:assert test="@size = 130">Incorrect size</s:assert>
               <s:assert test="starts-with(., '{')">Incorrect JSON content</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/directory/file[@uri='_stdout']">
               <s:assert test="string(.) = ''">Stdout should be empty</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
</t:test>
