issue-160-001

Tests that a variable defined as a function can be evaluated later on.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:ex="https://xmlcalabash.com/ns/examples" xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0"
                xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-inline-prefixes="ex xs cx"
                name="main" version="3.0">
   <p:import href="https://xmlcalabash.com/ext/library/pipeline-messages.xpl"/>
   <p:output port="result"/>
   <p:variable name="ex:document-info" as="function(*)"
               select="function($d as item()) as xs:string                       { p:document-property($d, 'content-type')                         || ' at ' || p:document-property($d, 'base-uri') }"/>
   <p:identity>
      <p:with-input>
         <doc/>
      </p:with-input>
   </p:identity>
   <p:identity name="id"
               message="Seeing { $ex:document-info(.) }"/>
   <cx:pipeline-messages p:depends="id" level="info"
                         clear="true"/>
</p:declare-step>

Result

<cx:messages xmlns:cx="http://xmlcalabash.com/ns/extensions"
             xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <cx:message date="2025-06-19T18:02:27X" level="INFO"
               message="Seeing application/xml at file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/issue-160-001.xml"/>
</cx:messages>

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="cx"
         uri="http://xmlcalabash.com/ns/extensions"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="cx:messages">The document root is not correct.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/cx:messages">
         <s:assert test="cx:message[@level='INFO' and contains(@message, 'Seeing application/xml')]">Did not find user message.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

20 Jan 2025, Norm Tovey-Walsh
Fixed typo in the test title.
19 Jan 2025, Norm Tovey-Walsh
Created test.