<?xml-stylesheet type="text/xsl" href="/style/testcase.xsl"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite"
        xmlns:p="http://www.w3.org/ns/xproc"
        xmlns:c="http://www.w3.org/ns/xproc-step"
        xmlns:err="http://www.w3.org/ns/xproc-error">
  <t:title>Test iteration #002</t:title>
  
  <t:description xmlns="http://www.w3.org/1999/xhtml">
    <p>Test <code>p:iteration-position()</code> and
    <code>p:iteration-size()</code>.</p>
  </t:description>

  <t:input port="source">
    <t:document>
      <doc>
        <title>Some title</title>
        <para>Some paragraph.</para>
        <para class="replaceme">Some paragraph.</para>
        <para>Some paragraph.</para>
        <para>Some paragraph.</para>
      </doc>
    </t:document>
  </t:input>
  
  <t:pipeline>
    <p:pipeline version='1.0'>
      <p:string-replace match="para[@class]/text()">
	<p:with-option name="replace"
		       select="concat('&quot;',p:iteration-position(), ' of ', p:iteration-size(),'&quot;')"/>
      </p:string-replace>
    </p:pipeline>
  </t:pipeline>
  
  <t:output port="result">
    <doc>
      <title>Some title</title>
      <para>Some paragraph.</para>
      <para class="replaceme">1 of 1</para>
      <para>Some paragraph.</para>
      <para>Some paragraph.</para>
    </doc>
  </t:output>
</t:test>

