xpath-003

Tests that if cx:xpath returns a string, it’s a text document not a JSON document. This is a test for #755, although that issue is broader than this step.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.2">
   <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>

Result

<ctype xmlns:cx="http://xmlcalabash.com/ns/extensions"
       xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:t="http://xproc.org/ns/testsuite/3.0">text/plain</ctype>

Schematron checks

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
          xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
   <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>

Revision history

16 Jul 2026, Norm Tovey-Walsh
Set pipeline version to 3.2 because of backwards compatibility issues.
13 Jul 2026, Norm Tovey-Walsh
Created test.