An XSLT 1.0+ implementation written entirely in JavaScript.
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
- <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>
- function-available()
- current()
- document()
- format-number()
- replace()
- lower-case()
- upper-case()
- matches()
- generateId()
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.
npm install XSLTjs --save 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) {
...
}
});
- 0.0.1
- Work in progress
Grant Vergottini- @grantcv1 - grant.vergottini@xcential.com
Distributed under the MIT license. See LICENSE for more information.
https://github.com/Xcential-Corporation/XSLTjs
- Fork it (https://github.com/yourname/yourproject/fork)
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request