Skip to content

obujor/XSLTjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XSLTjs

An XSLT 1.0+ implementation written entirely in JavaScript.

NPM Version Downloads Stats

Introduction

THIS IS STILL A WORK IN PROGRESS.

This is a partial implementation of XSLT 1.0, along with some 2.0 functions. Among its features:

  • Pure 100% JavaScript implementation requiring no C++, C#, or Java binding
  • Support for XML namespaces
  • Drop-in compatibility with xslt4node

XSLT elements supported

  • <xsl:apply-templates>
  • <xsl:attribute>
  • <xsl:call-template>
  • <xsl:choose>
  • <xsl:comment>
  • <xsl:copy>
  • <xsl:copy-of>
  • <xsl:decimal-format>
  • <xsl:element>
  • <xsl:for-each>
  • <xsl:function> (coming soon)
  • <xsl:if>
  • <xsl:import> (coming soon)
  • <xsl:include> (coming soon)
  • <otherwise>
  • <xsl:output>
  • <xsl:param>
  • <xsl:processing-instruction>
  • <sort>
  • <stylesheet>
  • <transform>
  • <template>
  • <text>
  • <value-of>
  • <variable>
  • <when>
  • <with-param>

XSLT XPath functions supported (beyond those from the XPath module)

  • function-available()
  • current()
  • document()
  • format-number()
  • replace()
  • lower-case()
  • upper-case()
  • matches()
  • generateId()

Acknowledgements

XSLTjs is based on the original work, AJAXSLT, developed by Steffen Meschkat at Google. That version was originally developed around 2005 as a stopgap solution for "fat web pages" at a time when XSLT processors weren't found in all web browsers.

This version is a substantial reworking of that original work for use in Node.js (other uses will need accommodation). Below is a partial list of enhancements:

  • Substantial rewrite to ES2015 standards
  • Fomatting of JavaScript to SemiStandard.
  • Replacement of internal implementations of XML DOM and XPath with XmlDOM and XPath modules available from NPM.
  • Support for namespaces
  • Support for extended (but still partial) set of XSLT functions used with XPath expressions.
  • Support for extended set of XSLT elements.
  • Drop-in compatibility with xslt4node.

At this point, features are being added as needed on our projects. Contributions are always welcome.

Installation

npm install XSLTjs --save

Usage example

  const transformSpec = {
    source: inputXML,
    xslt: transformXML,
    result: String,
    params: {
      'docName': 'My Document',
      'docDate': 'February 24, 2019'
    }
  };
  XSLT.transform(transformSpec, (errorMessage, resultXML) => {
    if (errorMessage) {
      throw new Error(error);
    } else if (resultXML) {
      ...
    }
  });

References

Release History

  • 0.0.1
    • Work in progress

Meta

Grant Vergottini- @grantcv1 - grant.vergottini@xcential.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/Xcential-Corporation/XSLTjs

Contributing

  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

About

An XSLT 1.0+ implementation written entirely in JavaScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors