xslt-processor 4.6.0 → 4.7.0
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 +28 -31
- package/index.d.mts +565 -241
- package/index.d.ts +565 -241
- package/index.js +14055 -5313
- package/index.js.map +1 -1
- package/index.mjs +14109 -5367
- package/index.mjs.map +1 -1
- package/package.json +12 -3
- package/umd/xslt-processor.global.js +6 -3
- package/umd/xslt-processor.global.js.map +1 -1
package/README.md
CHANGED
|
@@ -61,23 +61,6 @@ xslt.xsltProcess(
|
|
|
61
61
|
});
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
To access the XPath parser, you can use the instance present at `Xslt` class:
|
|
65
|
-
|
|
66
|
-
```js
|
|
67
|
-
const xslt = new Xslt();
|
|
68
|
-
const xPath = xslt.xPath;
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Or you can import it like this:
|
|
72
|
-
|
|
73
|
-
```js
|
|
74
|
-
import { XPath } from 'xslt-processor'
|
|
75
|
-
|
|
76
|
-
const xPath = new XPath();
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
`XPath` class is an external dependency, [living in its own repository](https://github.com/DesignLiquido/xpath).
|
|
80
|
-
|
|
81
64
|
If you write pre-2015 JS code, make adjustments as needed.
|
|
82
65
|
|
|
83
66
|
### `Xslt` class options
|
|
@@ -158,38 +141,50 @@ You can simply add a tag like this:
|
|
|
158
141
|
|
|
159
142
|
All the exports will live under `globalThis.XsltProcessor` and `window.XsltProcessor`. [See a usage example here](https://github.com/DesignLiquido/xslt-processor/blob/main/interactive-tests/xslt.html).
|
|
160
143
|
|
|
144
|
+
## XPath Parser
|
|
145
|
+
|
|
146
|
+
To access the XPath parser, you can use the instance present at `Xslt` class:
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
const xslt = new Xslt();
|
|
150
|
+
const xPath = xslt.xPath;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Or you can import it like this:
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
import { XPath } from 'xslt-processor'
|
|
157
|
+
|
|
158
|
+
const xPath = new XPath();
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`XPath` class is an external dependency, [living in its own repository](https://github.com/DesignLiquido/xpath).
|
|
162
|
+
|
|
161
163
|
## Introduction
|
|
162
164
|
|
|
163
|
-
XSLT-processor contains an implementation of XSLT in JavaScript. Because XSLT uses XPath, it also contains an implementation of XPath that can be used
|
|
164
|
-
independently of XSLT. This implementation has the advantage that it makes XSLT uniformly available whenever the browser's native `XSLTProcessor()`
|
|
165
|
+
XSLT-processor contains an implementation of XSLT in JavaScript. Because XSLT uses XPath, it also contains an implementation of XPath that can be used independently of XSLT. This implementation has the advantage that it makes XSLT uniformly available whenever the browser's native `XSLTProcessor()`
|
|
165
166
|
is not available such as in Node.js or in web workers.
|
|
166
167
|
|
|
167
|
-
XSLT-processor builds on Google's [AJAXSLT](https://github.com/4031651/ajaxslt) which was written before `XSLTProcessor()` became available in browsers, but the
|
|
168
|
-
code base has been updated to comply with ES2015+ and to make it work outside of browsers.
|
|
168
|
+
XSLT-processor builds on Google's [AJAXSLT](https://github.com/4031651/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.
|
|
169
169
|
|
|
170
|
-
This implementation of XSLT operates at the DOM level on its input documents.
|
|
171
|
-
It internally uses a DOM implementation to create the output document, but usually
|
|
172
|
-
returns the output document as text stream. The DOM to construct the output document can
|
|
173
|
-
be supplied by the application, or else an internal minimal DOM implementation is used. This
|
|
174
|
-
DOM comes with a minimal XML parser that can be used to generate a suitable DOM
|
|
175
|
-
representation of the input documents if they are present as text.
|
|
170
|
+
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 can be supplied by the application, or else an internal minimal DOM implementation is used. This DOM comes with a minimal XML parser that can be used to generate a suitable DOM representation of the input documents if they are present as text.
|
|
176
171
|
|
|
177
172
|
## Tests and usage examples
|
|
178
173
|
|
|
179
|
-
New tests are written in Jest an can be run by calling: `
|
|
174
|
+
New tests are written in Jest an can be run by calling: `yarn test`.
|
|
180
175
|
|
|
181
176
|
The files `xslt.html` and `xpath.html` in the directory `interactive-tests` are interactive tests. They can be run directly from the file system; no HTTP server is needed.
|
|
182
|
-
|
|
177
|
+
|
|
178
|
+
Both interactive tests and automatic tests demonstrate the use of the library functions.
|
|
183
179
|
|
|
184
180
|
## Conformance
|
|
185
181
|
|
|
186
182
|
A few features that are required by the XSLT and XPath standards were left out (but patches to add them are welcome).
|
|
183
|
+
|
|
187
184
|
See our [TODO](TODO.md) for a list of missing features that we are aware of (please add more items by means of PRs).
|
|
188
185
|
|
|
189
186
|
So far, we have implemented XQuery functions for versions 1.0 and 2.0, but this is not complete yet.
|
|
190
187
|
|
|
191
|
-
Issues are also marked in the source code using throw-statements.
|
|
192
|
-
|
|
193
188
|
The DOM implementation is minimal so as to support the XSLT processing, and not intended to be complete.
|
|
194
189
|
|
|
195
190
|
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.
|
|
@@ -257,6 +252,8 @@ Use `<xsl:preserve-space>` to preserve whitespace in specific elements, overridi
|
|
|
257
252
|
|
|
258
253
|
### Breaking Changes
|
|
259
254
|
|
|
255
|
+
Breaking changes are usually documented at every major release, but we also keep a short version of them below.
|
|
256
|
+
|
|
260
257
|
#### Version 2
|
|
261
258
|
|
|
262
259
|
Until version 2.3.1, use like the example below:
|