<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/ab-p-document-043.xml"
        name="ab-p-document-043.xml"
        expected="pass"
        features="webaccess">
   <t:info>
      <t:title>ab-p-document 043 (AB)</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-05-23</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Added static options for web server host and port.</p>
            </t:description>
         </t:revision>
         <t:revision>
            <t:date>2024-10-17</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Fixed typo.</p>
            </t:description>
         </t:revision>
         <t:revision>
            <t:date>2024-10-14</t:date>
            <t:author>
               <t:name>Achim Berndzen</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Initial check in</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Testing p:document: Redirects must be followed.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:fn="http://www.w3.org/2005/xpath-functions"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      version="3.0">
         <p:output port="result"/>
         <p:option name="WHOST" select="'http://localhost:8246'" static="true"/>
         <p:identity>
            <p:with-input>
               <p:document href="{$WHOST}/service/this-is-a"/>
            </p:with-input>
         </p:identity>
         <p:identity>
            <p:with-input>
               <result>
                  <prop>{p:document-property(., 'base-uri')}</prop>
                  <base>{fn:base-uri(.)}</base>
               </result>
            </p:with-input>
         </p:identity>
      </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="result">The document root is not 'result'.</s:assert>
               <s:assert test="result/prop">Document does not have a child element named 'prop'</s:assert>
               <s:assert test="ends-with(result/prop, '/service/this-is-d')">The text in element 'prop' is not right.</s:assert>
               <s:assert test="result/base">Document does not have a child element named 'base'</s:assert>
               <s:assert test="ends-with(result/base, '/service/this-is-d')">The text in element 'base' is not right.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="ab-p-document-043.xml">
      <result xmlns:fn="http://www.w3.org/2005/xpath-functions">
         <prop>http://apache2/service/this-is-d</prop>
         <base>http://apache2/service/this-is-d</base>
      </result>
   </t:result>
</t:test>
