AB for-each 005

Test evaluation of variables in the context of a p:for-each (ported from 1.0-testsuite/for-each-005)

Test ab-for-each-005.xml is expected to pass.

The pipeline


      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
            
         <p:output port="result"/>
         
         <p:input port="source">
            <p:inline>
               <doc xmlns="">
                  <para id="x1">Some paragraph.</para>
                  <para id="x2">Some paragraph.</para>
                  <para id="x3">Some paragraph.</para>
               </doc>
            </p:inline>
         </p:input>
         
         <p:for-each name="loop">
            <p:with-input select="/doc/para"/>
            
            <p:variable name="q" select="/para/@id" as="xs:string">
               <p:pipe step="loop" port="current"/>
            </p:variable>
            
            <p:choose>
               <p:when test="$q = 'x2'">
                  <p:identity/>
               </p:when>
               <p:otherwise>
                  <p:identity>
                     <p:with-input port="source">
                        <p:empty/>
                     </p:with-input>
                  </p:identity>
               </p:otherwise>
            </p:choose>
         </p:for-each>
         
         <p:wrap-sequence wrapper="newdoc"/>
      </p:declare-step>
   
MorganaXProc passing XML Calabash failing

Schematron validation


      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron">
         <s:pattern>
            <s:rule context="/">
               <s:assert test="newdoc">The document root is not 'newdoc'.</s:assert>            
               <s:assert test="newdoc/para">The root element does not have a child 'para'</s:assert>
               <s:assert test="count(newdoc/para)=1">The root element does not have ONE child 'para'.</s:assert>
               <s:assert test="newdoc/para/@id='x2'">The para element with @id='x2' was not selected.</s:assert>
               <s:assert test="newdoc/para='Some paragraph.'">The content of para element is not 'Some pharagraph.'</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   

Revision history

09 Jan 2019, Achim Berndzen

Initial test