Skip to content

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

License

Notifications You must be signed in to change notification settings

transpect/javascript-extension

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published