Choose 001

Test choose-001.xml is expected to pass.

The pipeline


<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" 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:otherwise>
         <p:identity>
            <p:with-input port="source">
               <p:inline>
                  <doc>none</doc>
               </p:inline>
            </p:with-input>
         </p:identity>
      </p:otherwise>
   </p:choose>
</p:declare-step>
MorganaXProc passing XML Calabash passing

Options

$match

select = '1'

Schematron validation


<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <s:ns prefix="c" uri="http://www.w3.org/ns/xproc-step"/>
   <s:pattern>
      <s:rule context="/*">
         <s:assert test="self::doc">The pipeline root is not doc.</s:assert>
         <s:assert test=". = 'one'">The result isn't "one"</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

24 Sep 2017 17:47, Norman Walsh

Port my test suite; add documentation and schemas