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 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.0.0/umd/xslt-processor.js"></script>
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
- XPath, it also contains an implementation of XPath that can be used
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
- which was written before `XSLTProcessor()` became available in browsers, but the
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
- documents. It internally uses a DOM implementation to create the
153
- output document, but usually returns the output document as text
154
- stream. The DOM to construct the output document can be supplied by
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,6 @@
1
1
  {
2
2
  "name": "xslt-processor",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "A JavaScript XSLT Processor",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -1,6 +1,7 @@
1
1
  import { XNode } from '../dom';
2
2
  import { XsltDecimalFormatSettings } from '../xslt/xslt-decimal-format-settings';
3
- /** XPath expression evaluation context. An XPath context consists of a
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;
@@ -0,0 +1,4 @@
1
+ import { ExprContext } from "../expr-context";
2
+ import { StringValue } from "../values";
3
+ export declare function upperCase(context: ExprContext): StringValue;
4
+ export declare function lowerCase(context: ExprContext): StringValue;
@@ -3,7 +3,7 @@ export declare class StringValue implements NodeValue {
3
3
  value: any;
4
4
  type: string;
5
5
  constructor(value: any);
6
- stringValue(): any;
6
+ stringValue(): string;
7
7
  booleanValue(): boolean;
8
8
  numberValue(): number;
9
9
  nodeSetValue(): void;
@@ -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