An extension step for XML Calabash to run JavaScript and NodeJS in XProc
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
io/transpect/calabash/extensions update class file Mar 20, 2018
lib update rhino and trireme Mar 20, 2018
src/main/java/io/transpect/calabash/extensions
test add test file for json2xml Feb 10, 2017
xmlcatalog update catalog Mar 20, 2018
LICENSE Initial commit Feb 10, 2017
README.md update readme Feb 10, 2017
javascript-declaration.xpl add XProc example and declaration Feb 10, 2017
javascript-example.xpl

README.md

javascript-extension

An extension step for XML Calabash to run JavaScript and NodeJS in XProc

Description

This step runs JavaScript code either by reading it from the input port or from a reference to an external file.

<tr:javascript>
  <p:with-option name="href" select="'test.js'"/>
</tr:javascript>
<tr:javascript>
  <p:inline>
    <c:data>
      print('hello world')
    </c:data>
  </p:inline>
</tr:javascript>

The step implements the JavaScript engines Rhino from Mozilla and Nashorn from Oracle and the trireme library from Apigee for running node.js scripts inside the JVM.

Requirements

  • Java 1.8

XML Calabash Configuration

  • add the path to JavaScriptExtension.java and the jar files in the lib directory to your Java classpath
  • edit your XProc config and add the class file
<xproc-config xmlns="http://xmlcalabash.com/ns/configuration" 
  xmlns:tr="http://transpect.io">

  <implementation type="tr:javascript" class-name="JavaScriptExtension"/>
    
</xproc-config>

Limitations

NodeJS code is just executed with Trireme and Rhino. Trireme doesn't support the newer JavaScript engine Nashorn. Please also note that there are differences between the JavaScript implementation of Rhino and NodeJS. There is a detailed list of supported features from Mozilla.