Choose 004

Test is expected to pass.

Options

NameInitializer
match'3'

The pipeline

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" name="main" version="3.0">
   <p:option name="match"/>
   <p:output port="result"/>
   <p:identity name="id">
      <p:with-input port="source">
         <p:inline document-properties="map { 'a': '1', 'b': '2' }">
            <doc/>
         </p:inline>
      </p:with-input>
   </p:identity>
   <p:choose name="choose">
      <p:when test="p:document-property(., 'a') = $match">
         <p:identity>
            <p:with-input port="source">
               <p:inline>
                  <doc>one</doc>
               </p:inline>
            </p:with-input>
         </p:identity>
      </p:when>
      <p:when test="p:document-property(., 'b') = $match">
         <p:identity>
            <p:with-input port="source">
               <p:inline>
                  <doc>two</doc>
               </p:inline>
            </p:with-input>
         </p:identity>
      </p:when>
   </p:choose>
   <p:wrap-sequence wrapper="result"/>
</p:declare-step>

Result

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

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <s:ns prefix="c"
         uri="http://www.w3.org/ns/xproc-step"/>
   <s:pattern>
      <s:rule context="/*">
         <s:assert test="self::result">The pipeline root is not result.</s:assert>
         <s:assert test="count(self::result/*)=1">The result document should not have one child.</s:assert>
         <s:assert test="self::result/doc">The child's name should be doc.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

10 Jun 2021, Achim Berndzen
Added attribute 'queryBinding' to schematron's schema.
03 Apr 2019, Achim Berndzen
Changed test because a missing p:otherwise is now an implicit identity.
02 Dec 2018, Achim Berndzen
Changed test, because it not an error anymore, if no p:when is selected and no p:otherwise is present.
09 Oct 2017, Norman Walsh
Fixed namespace
09 Oct 2017, Norman Walsh
Fixed namespace
24 Sep 2017, Norman Walsh
Port my test suite; add documentation and schemas