<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
  <t:info>
    <t:title>pdf-copy-001</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2026-06-11</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 pdf-copy removes compression.</p>
  </t:description>
  <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/pdf-steps.xpl"/>
  <p:output port="result"/>

  <p:load name="source" href="../documents/example.pdf"/>
  <cx:pdf-copy name="copy" compression="none"/>

  <cx:pdf-info name="source-info">
    <p:with-input pipe="@source"/>
  </cx:pdf-info>

  <cx:pdf-info name="copy-info">
    <p:with-input pipe="@copy"/>
  </cx:pdf-info>

  <p:wrap-sequence wrapper="wrapper">
    <p:with-input pipe="@source-info @copy-info"/>
  </p:wrap-sequence>
</p:declare-step>
  </t:pipeline>
  <t:schematron>
    <s:schema queryBinding="xslt2"
              xmlns:s="http://purl.oclc.org/dsdl/schematron">
      <s:ns prefix="cx" uri="http://xmlcalabash.com/ns/extensions"/>
      <s:ns prefix="f" uri="http://xmlcalabash.com/ns/acro-form"/>

      <s:pattern>
        <s:rule context="/">
          <s:assert test="wrapper">Wrong document element></s:assert>
        </s:rule>
      </s:pattern>

      <s:pattern>
        <s:rule context="/wrapper">
          <s:assert test="count(cx:pdf-info) = 2">Wrong number of PDF outputs</s:assert>
        </s:rule>
      </s:pattern>

      <s:pattern>
        <s:rule context="/wrapper/cx:pdf-info[1]">
          <s:assert test="ends-with(@href, 'documents/example.pdf')">First PDF isn’t example.pdf</s:assert>
          <s:assert test="cx:file-size = 115897">Wrong size</s:assert>
        </s:rule>
      </s:pattern>

      <s:pattern>
        <s:rule context="/wrapper/cx:pdf-info[2]">
          <s:assert test="not(@href)">Second PDF shouldn’t have a base URI</s:assert>
          <s:assert test="cx:file-size = 116327">Wrong size</s:assert>
        </s:rule>
      </s:pattern>

    </s:schema>
  </t:schematron>
</t:test>
