polyglot-004

Tests that the cx:python polyglot step returns XML.

Test polyglot-004.xml is expected to pass.

It requires the following features: polyglot.

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" version="3.0">
   <p:import href="https://xmlcalabash.com/ext/library/polyglot.xpl"/>
   <p:output port="result"/>
   <cx:python variables="map{'x': 7, 'y': 9, 'now': current-dateTime()}" result-content-type="application/xml">
      <p:with-input>
         <doc>Test</doc>
      </p:with-input>
      <p:with-option name="args" select="('a', 'b', 'c')"/>
      <p:with-input port="program">
         <p:inline content-type="text/plain" expand-text="false">
print("&lt;?xml version='1.0'?&gt;")
print(f"&lt;doc&gt;Testing {x*y}&lt;/doc&gt;")
          </p:inline>
      </p:with-input>
   </cx:python>
</p:declare-step>

Schematron validation

<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="doc">The root element is incorrect.</s:assert>
         <s:assert test="doc='Testing 63'">The document element value is incorrect.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

03 Jan 2025, Norm Tovey-Walsh

Created test.