<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/ab-pack-009.xml"
        name="ab-pack-009.xml"
        expected="pass">
   <t:info>
      <t:title>pack 009</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-02-01</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Created test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests that setting an xml:base attribute changes the base URI.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
         <p:output port="result"/>
         <p:pack wrapper="wrapper"
                 attributes="map{'pairs': true(), 'xml:base': 'http://example.com/'}">
            <p:with-input port="source">
               <doc1/>
               <doc2/>
            </p:with-input>
            <p:with-input port="alternate">
               <doc-a/>
               <doc-b/>
            </p:with-input>
         </p:pack>
         <p:for-each>
            <p:identity>
               <p:with-input select="p:document-properties(.)"/>
            </p:identity>
            <p:cast-content-type content-type="application/xml"/>
         </p:for-each>
         <p:wrap-sequence wrapper="sequence-wrapper"/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="sequence-wrapper">The document root is not sequence-wrapper.</s:assert>
               <s:assert test="sequence-wrapper/fn:map[1]/fn:string[@key='base-uri']                             = 'http://example.com/'">The first base URI is incorrect.</s:assert>
               <s:assert test="sequence-wrapper/fn:map[2]/fn:string[@key='base-uri']                             = 'http://example.com/'">The second base URI is incorrect.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="ab-pack-009.xml">
      <sequence-wrapper>
         <map xmlns="http://www.w3.org/2005/xpath-functions">
            <string key="content-type">application/xml</string>
            <string key="base-uri">http://example.com/</string>
         </map>
         <map xmlns="http://www.w3.org/2005/xpath-functions">
            <string key="content-type">application/xml</string>
            <string key="base-uri">http://example.com/</string>
         </map>
      </sequence-wrapper>
   </t:result>
</t:test>
