<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/elemental-001.xml"
        name="elemental-001.xml"
        expected="pass"
        features="elemental">
   <t:info>
      <t:title>elemental-001</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-08-16</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 cx:existdb runs against Elemental. This is really just a smoke
    test for the Elemental container.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      name="main"
                      version="3.0">
         <p:import href="https://xmlcalabash.com/ext/library/exist-db.xpl"/>
         <p:output port="result" sequence="true"/>
         <!-- By default eXist DB and Elemental have to use different ports. The
       mechanism for changing the ELEMENTAL option only works in CI. -->
         <p:option name="ELEMENTAL" select="'http://elemental:8090'" static="true"/>
         <cx:exist-db database-uri="{$ELEMENTAL}/exist/rest/db/"
                      query-parameters="map{'cache':'yes'}">
            <p:with-input>
               <p:empty/>
            </p:with-input>
            <p:with-input port="query">
               <p:inline content-type="text/plain">
&lt;doc&gt;{{3 + 4}}&lt;/doc&gt;
      </p:inline>
            </p:with-input>
         </cx:exist-db>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="exist" uri="http://exist.sourceforge.net/NS/exist"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="exist:result">The root is wrong.</s:assert>
               <s:assert test="exist:result[@exist:session]">No session.</s:assert>
               <s:assert test="exist:result/doc[. = '7']">The doc is wrong.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="elemental-001.xml">
      <exist:result xmlns:exist="http://exist.sourceforge.net/NS/exist"
                    exist:hits="1"
                    exist:start="1"
                    exist:count="1"
                    exist:session="0"
                    exist:compilation-time="1"
                    exist:execution-time="1">
         <doc>7</doc>
      </exist:result>
   </t:result>
</t:test>
