<?xml version="1.0" encoding="UTF-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        expected="pass"
        features="s3-collector">
  <t:info>
    <t:title>s3-href-004</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2025-10-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 unparsed-text works from S3</p>
  </t:description>

   <t:file-environment>
      <t:file path="file.xml">&lt;doc>It worked.&lt;/doc></t:file>
   </t:file-environment>

  <t:pipeline>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:cx="http://xmlcalabash.com/ns/extensions"
                name="main" version="3.0">
  <p:output port="result" sequence="true"/>

  <p:xslt>
    <p:with-input port="source"><doc/></p:with-input>
    <p:with-input port="stylesheet">
      <p:inline>
        <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                        xmlns:xs="http://www.w3.org/2001/XMLSchema"
                        exclude-result-prefixes="#all"
                        version="3.0">
          <xsl:template match="/">
            <text>
              <xsl:sequence
                  select="unparsed-text('s3://xmlcalabash-mock1/testfolder/file.xml')"/>
            </text>
          </xsl:template>
        </xsl:stylesheet>
      </p:inline>
    </p:with-input>
  </p:xslt>
</p:declare-step>
  </t:pipeline>
  <t:schematron>
    <s:schema queryBinding="xslt2"
              xmlns:s="http://purl.oclc.org/dsdl/schematron">
      <s:pattern>
        <s:rule context="/">
          <s:assert test="text = '&lt;doc>It worked.&lt;/doc>'"
                    >The result is wrong.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  </t:schematron>
</t:test>
