<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/pipelineception-014.xml"
        name="pipelineception-014.xml"
        expected="pass">
   <t:info>
      <t:title>pipelineception-014</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-05-10</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Fixed title.</p>
            </t:description>
         </t:revision>
         <t:revision>
            <t:date>2025-12-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>Test that a sequence passed to a function becomes a sequence
    of documents.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:ex="http://example.com/ns"
                      xmlns:map="http://www.w3.org/2005/xpath-functions/map"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      name="main"
                      version="3.0">
         <p:output port="result" sequence="true"/>
         <p:declare-step type="ex:pipeline">
            <p:input port="source" sequence="true"/>
            <p:output port="result"/>
            <p:count/>
         </p:declare-step>
         <p:declare-step type="ex:do-xslt">
            <p:output port="result"/>
            <p:xslt>
               <p:with-input>
                  <doc/>
               </p:with-input>
               <p:with-input port="stylesheet">
                  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                  exclude-result-prefixes="xs"
                                  version="3.0">
                     <xsl:template match="/">
                        <xsl:variable name="seq" select="(/*, map{{'text': 'Hello, world.'}}, 'string')"/>
                        <count>
                           <xsl:sequence select="string(ex:pipeline($seq)?result)"/>
                        </count>
                     </xsl:template>
                  </xsl:stylesheet>
               </p:with-input>
            </p:xslt>
         </p:declare-step>
         <ex:do-xslt/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="svg" uri="http://www.w3.org/2000/svg"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="count">The root is wrong.</s:assert>
               <s:assert test="count/. = '3'">The content is wrong.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="pipelineception-014.xml">
      <count xmlns:ex="http://example.com/ns"
             xmlns:map="http://www.w3.org/2005/xpath-functions/map">3</count>
   </t:result>
</t:test>
