<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <t:info>
      <t:title>Test for p:insert 004 (AB)</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2021-06-10</t:date>
            <t:author>
               <t:name>Achim Berndzen</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Added attribute 'queryBinding' to schematron's schema.</p>
            </t:description>
         </t:revision>
         <t:revision>
            <t:date>2019-03-22</t:date>
            <t:author>
               <t:name>Achim Berndzen</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Ported tests from 1.0 test suite</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests p:insert with position 'after'</p>
   </t:description>
   <t:pipeline>
      <p:declare-step version="3.0"
                      xmlns:p="http://www.w3.org/ns/xproc">
         <p:output port="result"/>
         <p:insert match="child::div/p[3]"
                   position="after">
            <p:with-input port="source">
               <div>
                  <p>First paragraph.</p>
                  <p>Middle paragraph.</p>
                  <p>Last paragraph.</p>
               </div>
            </p:with-input>
            <p:with-input port="insertion">
               <p:inline>
                  <p>New after paragraph.</p>
               </p:inline>
            </p:with-input>
         </p:insert>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema queryBinding="xslt2"
                xmlns:s="http://purl.oclc.org/dsdl/schematron"
                xmlns="http://www.w3.org/1999/xhtml">
         <s:pattern>
            <s:rule context="/">
               <s:assert test="div">The document root is not 'div'.</s:assert>
               <s:assert test="child::div/p[1]/text()='First paragraph.'">The text of the first p is not 'First paragraph'.</s:assert>
               <s:assert test="child::div/p[2]/text()='Middle paragraph.'">The text of the second p is not 'Middle paragraph'.</s:assert>
               <s:assert test="child::div/p[3]/text()='Last paragraph.'">The text of the third p is not 'Last paragraph'.</s:assert>
               <s:assert test="child::div/p[4]/text()='New after paragraph.'">The text of the last p is not 'New after paragraph'.</s:assert>
               <s:assert test="count(/div/p)=4">Root element does not have exactly four p-children.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
</t:test>