nw-empty-input-001

This test demonstrates and edge case. The user-defined step accepts zero or more documents on the source port, but has no default value called in a loop.

Test nw-empty-input-001.xml is expected to pass.

The pipeline


<p:declare-step xmlns:ex="http://example.com/ns/steps" xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
   <p:output port="result"/>
   <p:declare-step type="ex:accepts-nothing">
      <p:input port="source" primary="true" sequence="true"/>
      <p:input port="stylesheet"/>
      <p:output port="result"/>
      <p:xslt template-name="main">
         <p:with-input port="stylesheet" pipe="stylesheet"/>
      </p:xslt>
   </p:declare-step>
   <p:for-each>
      <p:with-input>
         <p:inline>
            <doc1/>
         </p:inline>
         <p:inline>
            <doc2/>
         </p:inline>
      </p:with-input>
      <ex:accepts-nothing>
         <p:with-input port="source">
            <p:empty/>
         </p:with-input>
         <p:with-input port="stylesheet">
            <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
               <xsl:template name="main">
                  <doc/>
               </xsl:template>
            </xsl:stylesheet>
         </p:with-input>
      </ex:accepts-nothing>
   </p:for-each>
   <p:wrap-sequence wrapper="wrapper"/>
</p:declare-step>

Schematron validation


<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="wrapper">The root element is not 'wrapper'.</s:assert>
         <s:assert test="count(wrapper/doc) = 2">Wrapper doesn’t contain two documents.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

05 Dec 2025, Norm Tovey-Walsh

Initial commit