polyglot-008
Tests that the cx:javascript polyglot step returns XML.
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.0">
<p:import href="https://xmlcalabash.com/ext/library/polyglot.xpl"/>
<p:output port="result"/>
<cx:javascript parameters="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">
console.log("<?xml version='1.0'?>")
console.log(`<doc>${x*y}</doc>`)
</p:inline>
</p:with-input>
</cx:javascript>
</p:declare-step>
Result
<doc xmlns:t="http://xproc.org/ns/testsuite/3.0">63</doc>
Schematron checks
<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
<s:pattern>
<s:rule context="/">
<s:assert test="doc">The root element is incorrect.</s:assert>
<s:assert test="doc='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.