<?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-merge-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-merge works.</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"/>

  <cx:pdf-merge>
    <p:with-input port="source" href="../documents/example.pdf"/>
    <p:with-input port="secondary">
      <p:document href="../documents/longer.pdf"/>
      <p:document href="../documents/libreoffice-form.pdf"/>
    </p:with-input>
  </cx:pdf-merge>

  <cx:pdf-info page-text="true"/>
</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="cx:pdf-info">Wrong document element></s:assert>
        </s:rule>
      </s:pattern>

      <s:pattern>
        <s:rule context="/cx:pdf-info">
          <s:assert test="cx:pages = 4">Wrong number of pages</s:assert>
          <s:assert test="starts-with(cx:page-details/cx:page[@page-number='4']/cx:text, 'Example for a Form')">Wrong page text</s:assert>
        </s:rule>
      </s:pattern>

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