<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
  <t:info>
    <t:title>pebble-009</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2025-12-25</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 the cx:pebble step preserves document properties.</p>
  </t:description>
  <t:pipeline>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:cx="http://xmlcalabash.com/ns/extensions"
                exclude-inline-prefixes="cx"
                name="main" version="3.0">
  <p:import href="https://xmlcalabash.com/ext/library/pebble.xpl"/>
  <p:output port="result" sequence="true"/>

  <p:set-properties properties='map{"a": 1, "test": "pass"}'
                    expand-text="false">
    <p:with-input>
      <doc><greeting>{{ greeting }}</greeting></doc>
    </p:with-input>
  </p:set-properties>

  <cx:pebble strictVariables="true"
             context="map{'greeting': 'Hello, world.'}"/>

  <p:identity>
    <p:with-input>
      <doc greeting="{/doc/greeting}" pass="{p:document-property(., 'test') = 'pass'}"/>
    </p:with-input>
  </p:identity>

</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="doc/@greeting = 'Hello, world.'">Template failed.</s:assert>
          <s:assert test="doc/@pass = 'true'">Properties failed.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  </t:schematron>
</t:test>
