xslt-processor 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -20
- package/package.json +1 -1
- package/umd/xslt/xslt.d.ts +1 -0
- package/umd/xslt-processor.js +1 -1
- package/umd/xslt-processor.js.map +1 -1
- package/xslt/xslt.d.ts +1 -0
- package/xslt/xslt.js +44 -14
- package/xslt/xslt.js.map +1 -1
package/README.md
CHANGED
|
@@ -87,7 +87,7 @@ const xslt = new Xslt(options);
|
|
|
87
87
|
You can simply add a tag like this:
|
|
88
88
|
|
|
89
89
|
```html
|
|
90
|
-
<script type="application/javascript" src="https://www.unpkg.com/xslt-processor@2.
|
|
90
|
+
<script type="application/javascript" src="https://www.unpkg.com/xslt-processor@2.1.0/umd/xslt-processor.js"></script>
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
All the exports will live under `globalThis.XsltProcessor`. [See a usage example here](https://github.com/DesignLiquido/xslt-processor/blob/main/interactive-tests/xslt.html).
|
|
@@ -137,25 +137,19 @@ These functions are part of `Xslt` and `XPath` classes, respectively, at version
|
|
|
137
137
|
|
|
138
138
|
## Introduction
|
|
139
139
|
|
|
140
|
-
XSLT-processor contains an implementation of XSLT in JavaScript. Because XSLT uses
|
|
141
|
-
|
|
142
|
-
independently of XSLT. This implementation has the advantage that it
|
|
143
|
-
makes XSLT uniformly available whenever the browser's native `XSLTProcessor()`
|
|
140
|
+
XSLT-processor contains an implementation of XSLT in JavaScript. Because XSLT uses XPath, it also contains an implementation of XPath that can be used
|
|
141
|
+
independently of XSLT. This implementation has the advantage that it makes XSLT uniformly available whenever the browser's native `XSLTProcessor()`
|
|
144
142
|
is not available such as in Node.js or in web workers.
|
|
145
143
|
|
|
146
|
-
XSLT-processor builds on Google's [AJAXSLT](https://github.com/4031651/ajaxslt)
|
|
147
|
-
|
|
148
|
-
code base has been updated to comply with ES2015+ and to make it work outside of
|
|
149
|
-
browsers.
|
|
144
|
+
XSLT-processor builds on Google's [AJAXSLT](https://github.com/4031651/ajaxslt) which was written before `XSLTProcessor()` became available in browsers, but the
|
|
145
|
+
code base has been updated to comply with ES2015+ and to make it work outside of browsers.
|
|
150
146
|
|
|
151
|
-
This implementation of XSLT operates at the DOM level on its input
|
|
152
|
-
|
|
153
|
-
output document
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
generate a suitable DOM representation of the input documents if they
|
|
158
|
-
are present as text.
|
|
147
|
+
This implementation of XSLT operates at the DOM level on its input documents.
|
|
148
|
+
It internally uses a DOM implementation to create the output document, but usually
|
|
149
|
+
returns the output document as text stream. The DOM to construct the output document can
|
|
150
|
+
be supplied by the application, or else an internal minimal DOM implementation is used. This
|
|
151
|
+
DOM comes with a minimal XML parser that can be used to generate a suitable DOM
|
|
152
|
+
representation of the input documents if they are present as text.
|
|
159
153
|
|
|
160
154
|
## Tests and usage examples
|
|
161
155
|
|
|
@@ -169,12 +163,13 @@ Both interactive tests and automatic tests demonstrate the use of the library fu
|
|
|
169
163
|
A few features that are required by the XSLT and XPath standards were left out (but patches to add them are welcome).
|
|
170
164
|
See our [TODO](TODO.md) for a list of missing features that we are aware of (please add more items by means of PRs).
|
|
171
165
|
|
|
166
|
+
So far, we have implemented XQuery functions for versions 1.0 and 2.0, but this is not complete yet.
|
|
167
|
+
|
|
172
168
|
Issues are also marked in the source code using throw-statements.
|
|
173
169
|
|
|
174
170
|
The DOM implementation is minimal so as to support the XSLT processing, and not intended to be complete.
|
|
175
171
|
|
|
176
|
-
The implementation is all agnostic about namespaces. It just expects
|
|
177
|
-
XSLT elements to have tags that carry the `xsl:` prefix, but we disregard all namespace declaration for them.
|
|
172
|
+
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.
|
|
178
173
|
|
|
179
174
|
[There are a few nonstandard XPath functions](https://github.com/search?q=repo%3ADesignLiquido%2Fxslt-processor%20ext-&type=code).
|
|
180
175
|
|
|
@@ -182,8 +177,12 @@ XSLT elements to have tags that carry the `xsl:` prefix, but we disregard all na
|
|
|
182
177
|
|
|
183
178
|
HTML per se is not strict XML. Because of that, starting on version 2.0.0, this library handles HTML differently than XML:
|
|
184
179
|
|
|
180
|
+
- For a document to be treated as HTML, it needs to have a `<!DOCTYPE>` tag defined with one of the following valid formats:
|
|
181
|
+
- `<!DOCTYPE html>` (for HTML5);
|
|
182
|
+
- `<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">` (for HTML4);
|
|
183
|
+
- `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">` (for XHTML 1.1).
|
|
185
184
|
- Tags like `<hr>`, `<link>` and `<meta>` don't need to be closed. The output for these tags doesn't close them (adding a `/` before the tag closes, or a corresponding close tag);
|
|
186
|
-
- This rule doesn't apply for XHTML, which is strict XML.
|
|
185
|
+
- This rule doesn't apply for XHTML, which is strict XML.
|
|
187
186
|
|
|
188
187
|
## References
|
|
189
188
|
|
package/package.json
CHANGED
package/umd/xslt/xslt.d.ts
CHANGED
|
@@ -148,6 +148,7 @@ export declare class Xslt {
|
|
|
148
148
|
* currently not implemented.
|
|
149
149
|
*/
|
|
150
150
|
protected xsltPassText(template: XNode): boolean;
|
|
151
|
+
protected xsltAttribute(attributeName: string, context: ExprContext): XNode;
|
|
151
152
|
/**
|
|
152
153
|
* Evaluates an XSL-T attribute value template. Attribute value
|
|
153
154
|
* templates are attributes on XSL-T elements that contain XPath
|