<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
  <t:info>
    <t:title>xpath-003</t:title>
    <t:revision-history>
      <t:revision>
        <t:date>2026-07-16</t:date>
        <t:author>
          <t:name>Norm Tovey-Walsh</t:name>
        </t:author>
        <t:description xmlns="http://www.w3.org/1999/xhtml">
          <p>Set pipeline version to 3.2 because of backwards
          compatibility issues.</p>
        </t:description>
      </t:revision>
      <t:revision>
        <t:date>2026-07-13</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 if cx:xpath returns a string, it’s a text document not a JSON
    document. This is a test for
    <a href="https://codeberg.org/xmlcalabash/xmlcalabash3/issues/755">#755</a>, although
    that issue is broader than this step.</p>
  </t:description>
  <t:pipeline>
    <p:declare-step version="3.2"
                    xmlns:err="http://www.w3.org/ns/xproc-error"
                    xmlns:cx="http://xmlcalabash.com/ns/extensions"
                    xmlns:p="http://www.w3.org/ns/xproc">
      <p:import href="https://xmlcalabash.com/ext/library/xpath.xpl"/>
      <p:output port="result"/>

      <cx:xpath>
        <p:with-input>
          <doc>Test</doc>
        </p:with-input>
        <p:with-input port="xpath">
          <p:inline content-type="text/plain" expand-text="false">"Hello, world."</p:inline>
        </p:with-input>
      </cx:xpath>

      <p:identity>
        <p:with-input>
          <ctype>{p:document-property(., 'content-type')}</ctype>
        </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:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
      <s:pattern>
        <s:rule context="/">
          <s:assert test="ctype = 'text/plain'">The content type is incorrect.</s:assert>
        </s:rule>
      </s:pattern>
    </s:schema>
  </t:schematron>
</t:test>
