npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

xjslt

v1.1.0

Published

xslt 2 transpiler to javascript

Readme

XJSLT - An XSLT to JavaScript transpiler

XJSLT is a substantially complete and performant XSLT 2.0 to JavaScript transpiler. XJSLT implements most features of XSLT 2 (see below for a few exceptions) and passes much of the test suite. XJSLT is written in TypeScript and depends on fontoxpath for an XPath implementation. XJSLT runs faster than SaxonJS in our experiments.

XJSLT works by compiling stylesheets to runnable JavaScript. These compiled stylesheets can be used immediately in the command line, or they can be save for later use in the command line. They can also be used programmatically either in the browser or in another JavaScript runtime.

XJSLT runs in javascript runtimes and on the browser. It has been tested with node and in Chrome and Firefox.

Getting started

Installation:

npm install -g xjslt

Or use

npx xjslt …

or from source:

git clone https://github.com/egh/xjslt.git && cd xjslt

Command line invocation:

npm exec -- xjslt run examples/jats-html.xsl examples/bmj_sample.xml

Compilation examples

XJSLT can compile XSLT stylesheets into executable JavaScript code, which can then be deployed to various platforms that support JavaScript, including the browser, NodeJS, and potentially other JavaScript runtimes. The following are some examples of how to do this for the browser, google cloud functions, and cloudflare edge functions. Note that this compiled .js may need to be recompiled if the xjslt version changes.

In the browser

For the following commands you will want to have the source checked out.

npm exec -- xjslt compile --web examples/jats-html.xsl examples/html/transform.js
  • Open examples/html/example.html (will load the generated transform.js file)

For reuse in the command line

Pre-compiling a .js file will speed up transformation.

npm exec -- xjslt compile examples/jats-html.xsl
npm exec -- xjslt run transform.js examples/bmj_sample.xml

Examples of use in cloud functions

XJSLT can be used to compile XSLT into JavaScript that can be used in, for example, cloud functions. Here are two examples of how it could be used in cloud functions to dynamically transform XML data into HTML.

In a google cloud function

npm exec -- xjslt compile --standalone examples/jats-html.xsl examples/google-cloud/transform.js
cd examples/google-cloud
npm install
npx @google-cloud/functions-framework --target=transform
  • Visit http://localhost:8080/?url=https://jats.nlm.nih.gov/publishing/tag-library/1.1/FullArticleSamples/bmj_sample.xml

In a cloudflare edge function

npm exec -- xjslt compile --standalone examples/jats-html.xsl examples/cloudflare/src/transform.js
cd examples/cloudflare
npm install
npm run start
  • Visit http://localhost:8787/?url=https://jats.nlm.nih.gov/publishing/tag-library/1.1/FullArticleSamples/bmj_sample.xml

Programmatic API (Node.js)

Use compile from xjslt/compile to build a transform function directly in Node.js without writing any files to disk. The stylesheet is passed as a parsed document, and the returned function can be called immediately.

import * as slimdom from "slimdom";
import { readFileSync } from "fs";
import { compile } from "xjslt/compile";

const stylesheetPath = "jats-html.xsl";
const xslt = slimdom.parseXmlDocument(readFileSync(stylesheetPath, "utf-8"));
const transform = compile(xslt);

// Transform an XML document
const input = slimdom.parseXmlDocument(readFileSync("article.xml", "utf-8"));
const results = transform(input);
const resultDocument = results.get("#default");

const xml = slimdom.serializeToWellFormedString(resultDocument);

console.log(xml);

Dynamic (not precompiled) use

xjslt can be used dynamically as well - that is, not precompiled. While precompiling the stylesheet is faster, this may be helpful in some circumstances.

In the browser

npm exec webpack && cp dist/xjslt-web.js examples/html/

Open examples/html/dynamic.html in your browser.

In node

(To be documented.)

Supported features

All core features of XSLT 2.0. Roughly 50% of tests in the XSLT test suite (https://github.com/w3c/xslt30-test) pass - but many of these tests are for edge cases.

Incompletely supported features

  • function basically working, with better typing TBD
  • output not all options supported
  • number basic support, not all options supported

TODO (not yet implemented)

  • [ ] analyze-string (depends on https://github.com/bwrrp/xspattern.js/issues/9)
  • [ ] tunneled parameters

Running tests

The test suite includes both unit tests and a subset of the W3C XSLT 3.0 test suite. To run tests, ensure dependencies are installed:

npm install

and then run tests:

npm test

Contributing

Some functionality, including import and include, is implemented in terms of preprocessors: xslt stylesheets that are applied to the xslt stylesheet itself before it is compiled. If you make changes that impact these preprocessors, you will need to run npm run build-preprocessors to recompile them.