xslt-processor 2.0.1 → 2.1.1
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 +12 -19
- package/package.json +1 -1
- package/umd/xpath/expr-context.d.ts +4 -2
- package/umd/xpath/functions/standard-20.d.ts +4 -0
- package/umd/xpath/values/string-value.d.ts +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/xpath/expr-context.d.ts +4 -2
- package/xpath/expr-context.js +7 -4
- package/xpath/expr-context.js.map +1 -1
- package/xpath/expressions/function-call-expr.js +3 -0
- package/xpath/expressions/function-call-expr.js.map +1 -1
- package/xpath/functions/standard-20.d.ts +4 -0
- package/xpath/functions/standard-20.js +18 -0
- package/xpath/functions/standard-20.js.map +1 -0
- package/xpath/values/string-value.d.ts +1 -1
- package/xpath/values/string-value.js +1 -1
- package/xpath/values/string-value.js.map +1 -1
- package/xslt/xslt.d.ts +1 -0
- package/xslt/xslt.js +42 -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,17 @@ 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
|
-
|
|
154
|
-
|
|
155
|
-
the application, or else an internal minimal DOM implementation is
|
|
156
|
-
used. This DOM comes with a minimal XML parser that can be used to
|
|
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. It internally uses a DOM implementation to create the
|
|
148
|
+
output document, but usually returns the output document as text stream. The DOM to construct the output document can be supplied by
|
|
149
|
+
the application, or else an internal minimal DOM implementation is used. This DOM comes with a minimal XML parser that can be used to
|
|
150
|
+
generate a suitable DOM representation of the input documents if they are present as text.
|
|
159
151
|
|
|
160
152
|
## Tests and usage examples
|
|
161
153
|
|
|
@@ -169,12 +161,13 @@ Both interactive tests and automatic tests demonstrate the use of the library fu
|
|
|
169
161
|
A few features that are required by the XSLT and XPath standards were left out (but patches to add them are welcome).
|
|
170
162
|
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
163
|
|
|
164
|
+
So far, we have implemented XQuery functions for versions 1.0 and 2.0, but this is not complete yet.
|
|
165
|
+
|
|
172
166
|
Issues are also marked in the source code using throw-statements.
|
|
173
167
|
|
|
174
168
|
The DOM implementation is minimal so as to support the XSLT processing, and not intended to be complete.
|
|
175
169
|
|
|
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.
|
|
170
|
+
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
171
|
|
|
179
172
|
[There are a few nonstandard XPath functions](https://github.com/search?q=repo%3ADesignLiquido%2Fxslt-processor%20ext-&type=code).
|
|
180
173
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { XNode } from '../dom';
|
|
2
2
|
import { XsltDecimalFormatSettings } from '../xslt/xslt-decimal-format-settings';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* XPath expression evaluation context. An XPath context consists of a
|
|
4
5
|
* DOM node, a list of DOM nodes that contains this node, a number
|
|
5
6
|
* that represents the position of the single node in the list, and a
|
|
6
7
|
* current set of variable bindings. (See XPath spec.)
|
|
@@ -39,6 +40,7 @@ export declare class ExprContext {
|
|
|
39
40
|
outputPosition: number;
|
|
40
41
|
outputNodeList: XNode[];
|
|
41
42
|
outputDepth: number;
|
|
43
|
+
xsltVersion: '1.0' | '2.0' | '3.0';
|
|
42
44
|
variables: {
|
|
43
45
|
[name: string]: any;
|
|
44
46
|
};
|
|
@@ -75,7 +77,7 @@ export declare class ExprContext {
|
|
|
75
77
|
* @param opt_returnOnFirstMatch TODO
|
|
76
78
|
* @param opt_ignoreNonElementNodesForNTA TODO
|
|
77
79
|
*/
|
|
78
|
-
constructor(nodeList: XNode[], outputNodeList: XNode[], opt_position?: number, opt_outputPosition?: number, opt_outputDepth?: number, opt_decimalFormatSettings?: XsltDecimalFormatSettings, opt_variables?: {
|
|
80
|
+
constructor(nodeList: XNode[], outputNodeList: XNode[], xsltVersion?: '1.0' | '2.0' | '3.0', opt_position?: number, opt_outputPosition?: number, opt_outputDepth?: number, opt_decimalFormatSettings?: XsltDecimalFormatSettings, opt_variables?: {
|
|
79
81
|
[name: string]: any;
|
|
80
82
|
}, opt_knownNamespaces?: {
|
|
81
83
|
[alias: string]: string;
|
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
|