Choose 004

Test choose-004.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:choose>
  
  <p:wrap-sequence wrapper="result"/>
</p:declare-step>
MorganaXProc passing XML Calabash passing

Options

$match

select = '3'

Schematron validation


     <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron">
         <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

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 21:11, Norman Walsh

Fixed namespace

09 Oct 2017 21:10, Norman Walsh

Fixed namespace

24 Sep 2017 17:47, Norman Walsh

Port my test suite; add documentation and schemas