<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/epubcheck-002.xml"
        name="epubcheck-002.xml"
        expected="pass">
   <t:info>
      <t:title>epubcheck-002</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-11-16</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 can be called in the EXProc namespace.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                      xmlns:err="http://www.w3.org/ns/xproc-error"
                      xmlns:ex="http://exproc.org/ns/steps"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      version="3.0">
         <p:import href="https://xmlcalabash.com/ext/library/epubcheck.xpl"/>
         <p:output port="result" pipe="report@epubcheck"/>
         <ex:epubcheck name="epubcheck" assert-valid="false">
            <p:with-input href="../epubcheck/epub-001.epub"/>
         </ex:epubcheck>
         <p:sink/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <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:result name="epubcheck-002.xml">
      <xvrl:report xmlns:xvrl="http://www.xproc.org/ns/xvrl">
         <xvrl:metadata>
            <xvrl:timestamp>2026-07-18T16:01:58.380551093Z</xvrl:timestamp>
            <xvrl:document href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/epubcheck/epub-001.epub"/>
         </xvrl:metadata>
         <xvrl:detection xmlns:epub="http://xmlcalabash.com/ns/epubcheck"
                         epub:path="/tmp/epub1213881880198343260.epub"
                         severity="error"
                         code="PKG-005">
            <xvrl:location href="file:/tmp/epub1213881880198343260.epub"/>
            <xvrl:message>The mimetype file has an extra field of length 20. The use of the extra field feature of the ZIP format is not permitted for the mimetype file.</xvrl:message>
         </xvrl:detection>
         <xvrl:detection xmlns:epub="http://xmlcalabash.com/ns/epubcheck"
                         epub:path="EPUB/package.opf"
                         severity="error"
                         code="RSC-026">
            <xvrl:location href="https://27301de7-7e9d-43d8-957f-11d997c215c4.epubcheck.w3c.org/EPUB/package.opf"
                           line="10"
                           column="105"/>
            <xvrl:message>URL "../../../../EPUB/content_001.xhtml" leaks outside the container (it is not a valid-relative-ocf-URL-with-fragment string)</xvrl:message>
         </xvrl:detection>
         <xvrl:detection xmlns:epub="http://xmlcalabash.com/ns/epubcheck"
                         epub:path="EPUB/package.opf"
                         severity="error"
                         code="RSC-026">
            <xvrl:location href="https://27301de7-7e9d-43d8-957f-11d997c215c4.epubcheck.w3c.org/EPUB/package.opf"
                           line="11"
                           column="111"/>
            <xvrl:message>URL "EPUB/../../../../EPUB/nav.xhtml" leaks outside the container (it is not a valid-relative-ocf-URL-with-fragment string)</xvrl:message>
         </xvrl:detection>
         <xvrl:digest valid="false"
                      fatal-error-count="0"
                      error-count="3"
                      warning-count="0"
                      info-count="0"
                      unspecified-count="0"
                      fatal-error-codes=""
                      error-codes="PKG-005 RSC-026"
                      warning-codes=""
                      info-codes=""
                      unspecified-codes=""
                      worst="error"/>
      </xvrl:report>
   </t:result>
</t:test>
