<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/nw-base-uri-023.xml"
        name="nw-base-uri-023.xml"
        expected="pass"
        features="send-mail">
   <t:info>
      <t:title>nw-base-uri-023</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-06-29</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>Test that the result of p:send-mail has no base URI.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:c="http://www.w3.org/ns/xproc-step"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      version="3.0">
         <p:output port="result"/>
         <p:option name="SHOST" select="'localhost'" static="true"/>
         <p:option name="SMTPPORT" select="1025" static="true"/>
         <p:option name="APIPORT" select="1080" static="true"/>
         <!-- Clear the Sendria log -->
         <p:http-request href="http://{$SHOST}:{$APIPORT}/api/messages/" method="delete">
            <p:with-input>
               <p:empty/>
            </p:with-input>
         </p:http-request>
         <!-- Make sure that succeeded -->
         <p:cast-content-type content-type="application/xml"/>
         <p:validate-with-schematron name="delete-check">
            <p:with-input port="schema">
               <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron">
                  <s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
                  <s:pattern name="Root must be map">
                     <s:rule context="/fn:map">
                        <s:assert test="fn:string[@key='code'] = 'OK'">Code must be 'OK'</s:assert>
                     </s:rule>
                  </s:pattern>
               </s:schema>
            </p:with-input>
         </p:validate-with-schematron>
         <!-- Send the email message -->
         <p:send-mail parameters="map{'host': $SHOST, 'port': $SMTPPORT, 'debug':false()}"
                      auth="map{'username':'username','password':'password'}"
                      depends="delete-check">
            <p:with-input>
               <p:inline>
                  <emx:Message xmlns:emx="URN:ietf:params:email-xml:" xmlns:rfc822="URN:ietf:params:rfc822:">
                     <rfc822:from>
                        <emx:Address>
                           <emx:adrs>mailto:user@example.com</emx:adrs>
                           <emx:name>Example User</emx:name>
                        </emx:Address>
                     </rfc822:from>
                     <rfc822:to>
                        <emx:Address>
                           <emx:adrs>mailto:anotheruser@example.com</emx:adrs>
                           <emx:name>Another User</emx:name>
                        </emx:Address>
                     </rfc822:to>
                     <rfc822:subject>Plain text email</rfc822:subject>
                     <emx:content type="text/plain">
          Do that thing.
        </emx:content>
                  </emx:Message>
               </p:inline>
            </p:with-input>
         </p:send-mail>
         <p:cast-content-type content-type="application/xml">
            <p:with-input select="p:document-properties(.)"/>
         </p:cast-content-type>
      </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:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="fn:map">Document element is wrong</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/fn:map">
               <s:assert test="not(exists(*[@key='base-uri']))">There should be no base-uri property</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="nw-base-uri-023.xml">
      <map xmlns="http://www.w3.org/2005/xpath-functions">
         <string key="content-type">application/xml</string>
      </map>
   </t:result>
</t:test>
