<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/ab-label-elements-003.xml"
        name="ab-label-elements-003.xml"
        expected="pass">
   <t:info>
      <t:title>label-elements 003 (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-05-04</t:date>
            <t:author>
               <t:name>Achim Berndzen</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Ported test 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>Testing p:label-elements.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
         <p:output port="result"/>
         <p:input port="source">
            <doc xml:base="http://example.com/base/">
               <chap xml:base="http://example.com/base/chaps/">
                  <para>...</para>
               </chap>
               <chap>
                  <para>...</para>
               </chap>
            </doc>
         </p:input>
         <p:label-elements label="concat(&#34;http://foo.com/&#34;, $p:index)"
                           attribute="xml:base"
                           match="chap"/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:pattern>
            <s:rule context="/">
               <s:assert test="doc">The document root is not 'doc'</s:assert>
               <s:assert test="base-uri(doc)='http://example.com/base/'">The base-uri of doc is not 'http://example.com/base/'.</s:assert>
               <s:assert test="doc/@xml:base='http://example.com/base/'">doc/@xml:base is not 'http://example.com/base/'.</s:assert>
               <s:assert test="doc/chap[1]">Root element does not have a child 'chap'.</s:assert>
               <s:assert test="base-uri(doc/chap[1])='http://foo.com/1'">The base-uri of chap[1] is not 'http://foo.com/1'.</s:assert>
               <s:assert test="doc/chap[1]/@xml:base='http://foo.com/1'">The @xml:base of chap[1] is not 'http://foo.com/1'.</s:assert>
               <s:assert test="doc/chap[1]/para/text()='...'">Element 'chap[1]' does not have a para child with '...'.</s:assert>
               <s:assert test="doc/chap[2]">Root element does not have two children 'chap'.</s:assert>
               <s:assert test="base-uri(doc/chap[2])='http://foo.com/2'">The base-uri of chap[2] is not 'http://foo.com/2'.</s:assert>
               <s:assert test="doc/chap[2]/@xml:base='http://foo.com/2'">The @xml:base of chap[2] is not 'http://foo.com/2'.</s:assert>
               <s:assert test="doc/chap[2]/para/text()='...'">Element 'chap[2]' does not have a para child with '...'.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="ab-label-elements-003.xml">
      <doc xml:base="http://example.com/base/">
         <chap xml:base="http://foo.com/1">
            <para>...</para>
         </chap>
         <chap xml:base="http://foo.com/2">
            <para>...</para>
         </chap>
      </doc>
   </t:result>
</t:test>
