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 🙏

© 2024 – Pkg Stats / Ryan Hefner

xslt-ts

v1.1.8

Published

XSL Transform 1.0 implemention for browser and Node.js environment.

Downloads

1,608

Readme

XSLT library

XSLT 1.0 implementation for browser and Node.js environment based on xpath-ts library.

Requirements

Release Notes

See CHANGELOG.md

Usage

Install with npm:

npm install xslt-ts

This library is xml engine agnostic but I recommend to use xmldom-ts, xmldom or jsdom

npm install xmldom-ts

or

npm install xmldom

or

npm install jsdom

simple usage:

import { DOMImplementationImpl, DOMParserImpl, XMLSerializerImpl } from 'xmldom-ts';
import { install, xsltProcess, xmlParse } from 'xslt-ts';

// xmlString: string of xml file contents
// xsltString: string of xslt file contents
// outXmlString: output xml string.
install(new DOMParserImpl(), new XMLSerializerImpl(), new DOMImplementationImpl());
const outXmlString = xsltProcess(xmlParse(xmlString), xmlParse(xsltString));

another type of usage:

import { DOMImplementationImpl, DOMParserImpl, XMLSerializerImpl } from 'xmldom-ts';
import { install, XSLTProcessor } from 'xslt-ts';

// xmlString: string of xml file contents
// xsltString: string of xslt file contents
// output: output DOM model
install(new DOMParserImpl(), new XMLSerializerImpl(), new DOMImplementationImpl());
const processor = new XSLTProcessorImpl();

processor.importStylesheet(xmlParse(xsltString));
const output = processor.transformToDocument(xmlParse(xmlString));

Introduction

This library contains an implementation of XSLT in TypeScript. Because XSLT uses XPath, it uses compatible XPath implementation xpath-ts which can be used independently of XSLT. This implementation has the advantage that it makes XSLT uniformly available whenever the browser's native XSLTProcessor() is not available such as in node.js or in web workers.

XSLT-processor builds on Google's AJAXSLT which was written before XSLTProcessor() became available in browsers, but the code base has been updated to comply with ES2015+ and to make it work outside of browsers.

This implementation of XSLT operates at the DOM level on its input documents. It internally uses a DOM implementation to create the output document, but usually returns the output document as text stream. The DOM to construct the output document must be supplied by the application. xmldom and jsdom are tested.

Conformance

A few features that are required by the XSLT and XPath standards were left out (but patches to add them are welcome). See our TODO for a list of missing features that we are aware of (please add more items by means of PRs).

Issues are also marked in the source code using throw-statements.

The implementation is all agnostic about namespaces. It just expects XSLT elements to have tags that carry the xsl: prefix, but we disregard all namespace declaration for them.

Developing and Testing

Download

git clone 'https://github.com/backslash47/xslt-ts'
cd xslt-ts

Install

npm install

Build

npm run build

You will get the transpiled code under '/dist/lib' and typings under '/dist/types'.

Test

Run standard tests with Mocha + Chai testing framework

npm test

Authors

  • Google Inc. - Initial work ajaxslt project
  • Johannes Wilm - ES2015+ rewrite Fiduswriter
  • Matus Zamborsky - TypeScript rewrite - Backslash47

References

  • XPath Specification http://www.w3.org/TR/1999/REC-xpath-19991116

  • XSLT Specification http://www.w3.org/TR/1999/REC-xslt-19991116

  • W3C DOM Level 3 Core Specification http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/

  • ECMAScript Language Specification http://www.ecma-international.org/publications/standards/Ecma-262.htm

Licence

The original sources of ajaxslt projects are licenced under BSD-3 clause AJAXSLT-LICENCE.md. Modification made after are licenced with GNU Lesser General Public License v3.0 - see the LICENCE.md file for details.