Package Exports
- xsltjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xsltjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
XSLTjs
An XSLT 1.0+ implementation written entirely in JavaScript.
Introduction
This is a partial implementation of XSLT 1.0 and XSLT 2.0. Among its features:
- Pure 100% JavaScript implementation requiring no C++, C#, or Java binding
- Support for XML namespaces
- Support for include/import
- Support for XSL-T functions
- 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>
- <xsl:if>
- <xsl:import>
- <xsl:include>
- <xsl:otherwise>
- <xsl:output>
- <xsl:param>
- <xsl:processing-instruction>
- <xsl:sort>
- <xsl:stylesheet>
- <xsl:transform>
- <xsl:template>
- <xsl:text>
- <xsl:value-of>
- <xsl:variable>
- <xsl:when>
- <xsl: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 AJAXSLT, originally developed by Steffen Meschkat at Google. That version was 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|inputDoc,
xsltPath: transformPath, // Optional
xslt: transformXML|transformDoc, // Optional
result: string|function,
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.6
- Implements include/import
- Bug fixes
- 0.0.5
- Implements functions
- Bug fixes
- 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
- 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