<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/nw-xinclude-001.xml"
        name="nw-xinclude-001.xml"
        expected="pass">
   <t:info>
      <t:title>nw-xinclude-001</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-05-17</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Initial commit.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests that the base URI is preserved correctly in nested inclusions.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="pipeline" version="3.0">
         <p:output port="result"/>
         <p:xinclude fixup-xml-base="false">
            <p:with-input href="../documents/four.xml"/>
         </p:xinclude>
         <p:add-xml-base/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://purl.oclc.org/dsdl/schematron"
                queryBinding="xslt2">
         <s:pattern>
            <s:rule context="/">
               <s:assert test="four">Root element is not 'four'.</s:assert>
               <s:assert test="ends-with(four/@xml:base, '/four.xml')">Four has wrong base uri.</s:assert>
               <s:assert test="ends-with(four/three/@xml:base, 'three.xml')">Three has wrong base uri.</s:assert>
               <s:assert test="ends-with(four/three/two/@xml:base, 'two.xml')">Two has wrong base uri.</s:assert>
               <s:assert test="ends-with(four/three/two/one/@xml:base, 'one.xml')">One has wrong base uri.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="nw-xinclude-001.xml">
      <four xmlns:xi="http://www.w3.org/2001/XInclude"
            xml:base="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/3.0-test-suite/test-suite/documents/four.xml">
         <three xml:base="three.xml">
            <two xml:base="two.xml">
               <one xml:base="one.xml"/>
            </two>
         </three>
      </four>
   </t:result>
</t:test>
