SaxonJS 3.0 is a major update to the SaxonJS product. In December 2024, it is being published as a preview release, version 3.0.0-beta1. This is a preview release of the SaxonJS 3.0 HE (Home Edition) product. An EE (Enterprise Edition) product is in the works.
New features in the beta1 release
This release includes a number of new features, with several more planned before the final 3.0 release.
Promises
SaxonJS 3 introduces new mechanisms for enabling asynchronous processing
using promises. A new instruction ixsl:promise
is introduced which
can be used as a replacement for the existing ixsl:schedule-action
instruction.
- The new instruction can now call any asychronous function to fetch any kind of resource. Adding new kinds of resource is just a question of implementing new functions (which can be user-written functions as well as system-supplied functions). So if you want to fetch data from a SQL database, for example, you can easily write a function to do that.
- The machinery for handling asynchronous requests is now closely aligned with JavaScript promises, both in terms of the conceptual design, and the implementation. This makes it much easier to understand for users familiar with the JavaScript processing model.
- The mechanism takes advantage of XDM higher-order functions. (Note, however, that it still “bends” the pure declarative approach of XPath by introducing mutability. A promise, for example, is a mutable object, so you need to exercise care for example if you bind it to a variable.)
Note that for Node.js, run time use of ixsl:promise is an EE feature. So XSLT
stylesheets using ixsl:promise
can be compiled to SEF with the XX
compiler in SaxonJS without a JS-EE license, and then run in the browser; but to
run such a stylesheet on Node.js requires SaxonJS-EE and a valid JS-EE license.
JavaScript extension functions
JavaScript developers have easy access to a huge variety of tools and
libraries distributed as JavaScript packages through npm
and other
mechanisms. We want to make those libraries easily accessible for SaxonJS
developers too.
In SaxonJS 3, you can define extension functions in JavaScript and call them
directly from XPath, both from SaxonJS.XPath.evaluate
and from
within XSLT stylesheets running on SaxonJS in the browser or on Node.js.
This opens up whole new horizons for SaxonJS developers.
Smaller changes and improvements
While a lot of our focus has been on larger improvements, a few less dramatic features are also debuting in beta1.
- Support XPath expressions (other than “.”) after ? in
xsl:result-document
- New methods on
xsl:result-document
:ixsl:replace-element
,ixsl:insert-before
, andixsl:insert-after
- Improved support for following HTTP redirects
- Improved support for accessing JavaScript objects with
ixsl:set-property
,ixsl:json-parse
,ixsl:new
,ixsl:apply
,ixsl:call
,ixsl:eval
, andixsl:get
- Support the
escape-solidus
option when generating JSON.
New features coming soon
Eager to publish a release, at this stage, we’ve opted only to publish the HE version of SaxonJS 3.0 as beta1. More work is planned before the general release, including SaxonJS 3.0 EE.
SaxonJS-EE
SaxonJS-HE will remain a free product, but in 2025 we will also be introducing a licensed version of SaxonJS, SaxonJS-EE. The licensed version will provide additional features on Node.js (such as built-in EXPath and Saxon extension functions).
The promises API run time will be a licensed feature on Node.js.
Calling XSLT functions from JavaScript
Many transformations, on XML and JSON, are easier to define in XSLT than in JavaScript. XSLT has a rich vocabulary of instructions for describing, constructing, and transforming data in a clear, descriptive, and functional way.
We anticipate making those features more accessible to JavaScript developers by allowing JavaScript to call functions defined in XSLT.
Adding a SaxonJS.compile API
The ability to construct an XSLT stylesheet and then compile it directly for
use in the current transformation is a powerful feature. A new API for doing this,
SaxonJS.compile
, will be added in the general release.
Getting started
You can try out SaxonJS-HE 3.0 today, the packages have been uploaded to npmjs.com: saxonjs-he and xslt3-he. You can also download them our website.
Our documentation pages have been updated and a repository of short examples has been published: SaxonJS3 demo.
We hope you’re as excited as we are and we look forward to your feedback. Please report any issues that you encounter on our issue tracker.