<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
  <t:info>
    <t:title>pipelineception-001</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2025-09-14</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 pipelineception works.</p>
  </t:description>
  <t:pipeline>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:ex="http://example.com/ns"
                name="main" version="3.0">
  <p:output port="result" sequence="true"/>

  <p:declare-step type="ex:process">
    <p:input port="source" content-types="xml html"/>
    <p:output port="result" content-types="xml html"/>
    <p:add-attribute attribute-name="do" attribute-value="something"/>
  </p:declare-step>

  <p:xslt>
    <p:with-input port="source">
      <doc>
        <could/>
      </doc>
    </p:with-input>
    <p:with-input port="stylesheet">
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      xmlns:ex="http://example.com/ns"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      exclude-result-prefixes="#all"
                      version="3.0">

        <xsl:output method="xml" encoding="utf-8" indent="no"/>

        <xsl:mode on-no-match="shallow-copy"/>

        <xsl:template match="doc">
          <doc>
            <title>What would I do?</title>
            <xsl:apply-templates/>
          </doc>
        </xsl:template>

        <xsl:template match="could">
          <xsl:sequence select="ex:process(.)?result"/>
        </xsl:template>
      </xsl:stylesheet>
    </p:with-input>
  </p:xslt>

</p:declare-step>
  </t:pipeline>
  <t:schematron>
    <s:schema queryBinding="xslt2"
              xmlns:s="http://purl.oclc.org/dsdl/schematron">
      <s:ns prefix="svg" uri="http://www.w3.org/2000/svg"/>
      <s:pattern>
        <s:rule context="/">
          <s:assert test="doc">The root is wrong.</s:assert>
        </s:rule>
      </s:pattern>
      <s:pattern>
        <s:rule context="/doc">
          <s:assert test="could[@do = 'something']">The attribute hasn’t been added.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  </t:schematron>
</t:test>
