p:choose-030 (AB)

Test p:choose with different named secondary output ports.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
   <p:output port="result"/>
   <p:choose name="choose">
      <p:when test="true()">
         <p:output port="result" primary="true"/>
         <p:output port="when-output">
            <when/>
         </p:output>
         <p:identity>
            <p:with-input>
               <true/>
            </p:with-input>
         </p:identity>
      </p:when>
      <p:otherwise>
         <p:output port="result" primary="true"/>
         <p:output port="otherwise-output">
            <otherwise/>
         </p:output>
         <p:identity>
            <p:with-input>
               <false/>
            </p:with-input>
         </p:identity>
      </p:otherwise>
   </p:choose>
   <p:wrap-sequence name="wrap1" wrapper="when">
      <p:with-input pipe="when-output@choose"/>
   </p:wrap-sequence>
   <p:wrap-sequence name="wrap2" wrapper="otherwise">
      <p:with-input pipe="otherwise-output@choose"/>
   </p:wrap-sequence>
   <p:wrap-sequence wrapper="result">
      <p:with-input pipe="@choose @wrap1 @wrap2"/>
   </p:wrap-sequence>
</p:declare-step>

Result

<result xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <true/>
   <when>
      <when/>
   </when>
   <otherwise/>
</result>

Schematron checks

<s:schema xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://purl.oclc.org/dsdl/schematron" xmlns:t="http://xproc.org/ns/testsuite/3.0"
          queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="/result">Root element is not 'result'.</s:assert>
         <s:assert test="/result/*[1]/name()='true'">The first child of result is not named 'true'.</s:assert>
         <s:assert test="/result/*[2]/name()='when'">The second child of result is not named 'when'.</s:assert>
         <s:assert test="/result/when/when">'when' does not have a child 'when'.</s:assert>
         <s:assert test="/result/*[3]/name()='otherwise'">The third child of result is not named 'otherwise'.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

10 Jun 2021, Achim Berndzen
Added attribute 'queryBinding' to schematron's schema.
05 Apr 2019, Achim Berndzen
New tests