<?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-006</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2025-09-19</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 pipeline with only options works.</p>
  </t:description>
  <t:pipeline>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:xs="http://www.w3.org/2001/XMLSchema" 
                xmlns:ex="http://example.com/ns"
                exclude-inline-prefixes="#all"
                name="main" version="3.0">
  <p:output port="result" sequence="true"/>

  <p:declare-step type="ex:test-pipeline">
    <p:output port="result" content-types="xml"/>
    <p:option name="opt" as="xs:string?"/>
    <p:choose>
      <p:when test="empty($opt)">
        <p:identity>
          <p:with-input><test-output/></p:with-input>
        </p:identity>
      </p:when>
      <p:otherwise>
        <p:identity>
          <p:with-input><test-output opt="{$opt}"/></p:with-input>
        </p:identity>
      </p:otherwise>
    </p:choose>
  </p:declare-step>

  <p:identity>
    <p:with-input>
      <wrapper>{ex:test-pipeline(map{'opt':'has-value'})?result}</wrapper>
    </p:with-input>
  </p:identity>

</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="wrapper">The root is wrong.</s:assert>
          <s:assert test="wrapper/test-output">The content is wrong.</s:assert>
          <s:assert test="wrapper/test-output/@opt = 'has-value'">The attribute is wrong.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  </t:schematron>
</t:test>
