<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
  <t:info>
    <t:title>epubcheck-001</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2025-01-02</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 that the epubcheck step writes a report.</p>
  </t:description>
  <t:pipeline>
    <p:declare-step version="3.0"
                    xmlns:err="http://www.w3.org/ns/xproc-error"
                    xmlns:cx="http://xmlcalabash.com/ns/extensions"
                    xmlns:p="http://www.w3.org/ns/xproc">
      <p:import href="https://xmlcalabash.com/ext/library/epubcheck.xpl"/>
      <p:output port="result" pipe="report@epubcheck"/>

      <cx:epubcheck name="epubcheck" assert-valid="false">
        <p:with-input href="../epubcheck/epub-001.epub"/>
      </cx:epubcheck>

      <p:sink/>
    </p:declare-step>
  </t:pipeline>
  <t:schematron>
    <s:schema queryBinding="xslt2"
              xmlns:s="http://purl.oclc.org/dsdl/schematron">
      <s:ns prefix="xvrl" uri="http://www.xproc.org/ns/xvrl"/>
      <s:pattern>
        <s:rule context="/">
          <s:assert test="xvrl:report">The document root is not correct.</s:assert>
        </s:rule>
      </s:pattern>
      <s:pattern>
        <s:rule context="/xvrl:report">
          <s:assert test="xvrl:detection[@code='PKG-005']">Error PKG-005 not reported.</s:assert>
          <s:assert test="xvrl:detection[@code='RSC-026']">Error RSC-026 not reported.</s:assert>
          <s:assert test="xvrl:digest/@error-count = 3">Wrong number of errors reported.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  </t:schematron>
</t:test>
