AB for-each 003

Test p:for-each p:iteration-size() and p:iteration-position()(ported from 1.0-testsuite/for-each-003)

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

The pipeline


      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
            
         <p:input port="source"/>
         <p:output port="result"/>
         
         <p:for-each name="for">
            <p:with-input select="//para"/>
            
            <p:choose>
               <p:when test="p:iteration-position() = 1">
                  <p:identity>
                     <p:with-input port="source">
                        <p:inline><first xmlns=""/></p:inline>
                        <p:pipe step="for" port="current"/>
                     </p:with-input>
                  </p:identity>
               </p:when>
               <p:when test="p:iteration-position() = p:iteration-size()">
                  <p:identity>
                     <p:with-input port="source">
                        <p:pipe step="for" port="current"/>
                        <p:inline><last xmlns=""/></p:inline>
                     </p:with-input>
                  </p:identity>
               </p:when>
               <p:otherwise>
                  <p:identity/>
               </p:otherwise>
            </p:choose>
         </p:for-each>
         <p:wrap-sequence wrapper="wrapper"/>
      </p:declare-step>
   
MorganaXProc passing XML Calabash failing

Inputs

port = source


      <doc>
         <title>Some title</title>
         <para>Paragraph 1.</para>
         <para>Paragraph 2.</para>
         <para>Paragraph 3.</para>
      </doc>
   

Schematron validation


      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron">
         <s:pattern>
            <s:rule context="/">
               <s:assert test="wrapper">The document root is not wrapper.</s:assert>
               <s:assert test="wrapper/*[1]/name()='first'">First child of wrapper is not 'first'.</s:assert>
               <s:assert test="wrapper/*[2]/name()='para'">Second child of wrapper is not 'para'.</s:assert>
               <s:assert test="wrapper/*[3]/name()='para'">Third child of wrapper is not 'para'.</s:assert>
               <s:assert test="wrapper/*[4]/name()='para'">Fourth child of wrapper is not 'para'.</s:assert>
               <s:assert test="wrapper/*[5]/name()='last'">Fifth child of wrapper is not 'last'.</s:assert>
               
               <s:assert test="count(wrapper/*)=5">Wrapper does not have five children.</s:assert>
               
               <s:assert test="wrapper/para[1]/text()='Paragraph 1.'">Content of first para child is not 'Paragraph 1.'</s:assert>
               <s:assert test="wrapper/para[2]/text()='Paragraph 2.'">Content of second para child is not 'Paragraph 2.'</s:assert>
               <s:assert test="wrapper/para[3]/text()='Paragraph 3.'">Content of thrid para child is not 'Paragraph 3.'</s:assert>
               
            </s:rule>
         </s:pattern>
      </s:schema>
   

Revision history

16 Mar 2019, Achim Berndzen

Fixed test by getting patterns right.

08 Jan 2019, Achim Berndzen

Initial test