<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="merge-properties-001.xml"
        name="merge-properties-001.xml"
        expected="pass">
   <t:info>
      <t:title>merge-properties-001</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-09-04</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 merge properties merges distinct properties.</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/merge-properties.xpl"/>
         <p:output port="result"/>
         <p:set-properties name="alternate" properties="map{'A': 'alternate', 'B': 'alternate'}">
            <p:with-input>
               <doc/>
            </p:with-input>
         </p:set-properties>
         <p:set-properties name="original" properties="map{'A': 'original'}">
            <p:with-input>
               <doc/>
            </p:with-input>
         </p:set-properties>
         <cx:merge-properties>
            <p:with-input port="alternate" pipe="@alternate"/>
         </cx:merge-properties>
         <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:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="map" uri="http://www.w3.org/2005/xpath-functions"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="map:map">The root is wrong.</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/map:map">
               <s:assert test="map:string[@key='A']='original'">A is not original</s:assert>
               <s:assert test="map:string[@key='B']='alternate'">B is not alternate</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="merge-properties-001.xml">
      <map xmlns="http://www.w3.org/2005/xpath-functions">
         <string key="content-type">application/xml</string>
         <string key="A">original</string>
         <string key="B">alternate</string>
         <string key="base-uri">file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/merge-properties-001.xml</string>
      </map>
   </t:result>
</t:test>
