xslt-processor 3.0.1 → 3.0.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/constants.d.ts +12 -12
- package/constants.js +16 -16
- package/dom/functions.d.ts +14 -14
- package/dom/functions.js +56 -57
- package/dom/functions.js.map +1 -1
- package/dom/index.d.ts +6 -6
- package/dom/index.js +22 -22
- package/dom/util.d.ts +7 -7
- package/dom/util.js +42 -43
- package/dom/util.js.map +1 -1
- package/dom/xdocument.d.ts +16 -16
- package/dom/xdocument.js +73 -74
- package/dom/xdocument.js.map +1 -1
- package/dom/xml-functions.d.ts +58 -58
- package/dom/xml-functions.js +369 -370
- package/dom/xml-functions.js.map +1 -1
- package/dom/xml-output-options.d.ts +6 -6
- package/dom/xml-output-options.js +2 -2
- package/dom/xml-parser.d.ts +47 -47
- package/dom/xml-parser.js +307 -307
- package/dom/xml-parser.js.map +1 -1
- package/dom/xmltoken.d.ts +12 -12
- package/dom/xmltoken.js +101 -101
- package/dom/xnode.d.ts +73 -73
- package/dom/xnode.js +450 -450
- package/dom/xnode.js.map +1 -1
- package/index.d.ts +4 -4
- package/index.js +12 -12
- package/package.json +7 -7
- package/test-without-jest.d.ts +1 -0
- package/test-without-jest.js +63 -0
- package/test-without-jest.js.map +1 -0
- package/umd/constants.d.ts +12 -12
- package/umd/dom/functions.d.ts +14 -14
- package/umd/dom/index.d.ts +6 -6
- package/umd/dom/util.d.ts +7 -7
- package/umd/dom/xdocument.d.ts +16 -16
- package/umd/dom/xml-functions.d.ts +58 -58
- package/umd/dom/xml-output-options.d.ts +6 -6
- package/umd/dom/xml-parser.d.ts +47 -47
- package/umd/dom/xmltoken.d.ts +12 -12
- package/umd/dom/xnode.d.ts +73 -73
- package/umd/index.d.ts +4 -4
- package/umd/test-without-jest.d.ts +1 -0
- package/umd/xpath/common-function.d.ts +8 -8
- package/umd/xpath/expr-context.d.ts +111 -111
- package/umd/xpath/expressions/binary-expr.d.ts +11 -11
- package/umd/xpath/expressions/expression.d.ts +4 -4
- package/umd/xpath/expressions/filter-expr.d.ts +9 -9
- package/umd/xpath/expressions/function-call-expr.d.ts +12 -12
- package/umd/xpath/expressions/index.d.ts +13 -13
- package/umd/xpath/expressions/literal-expr.d.ts +7 -7
- package/umd/xpath/expressions/location-expr.d.ts +15 -15
- package/umd/xpath/expressions/number-expr.d.ts +7 -7
- package/umd/xpath/expressions/path-expr.d.ts +9 -9
- package/umd/xpath/expressions/predicate-expr.d.ts +8 -8
- package/umd/xpath/expressions/step-expr.d.ts +25 -25
- package/umd/xpath/expressions/token-expr.d.ts +7 -7
- package/umd/xpath/expressions/unary-minus-expr.d.ts +8 -8
- package/umd/xpath/expressions/union-expr.d.ts +9 -9
- package/umd/xpath/expressions/variable-expr.d.ts +7 -7
- package/umd/xpath/functions/index.d.ts +2 -2
- package/umd/xpath/functions/internal-functions.d.ts +2 -2
- package/umd/xpath/functions/non-standard.d.ts +12 -12
- package/umd/xpath/functions/standard-20.d.ts +5 -5
- package/umd/xpath/functions/standard.d.ts +40 -40
- package/umd/xpath/grammar-rule-candidate.d.ts +8 -8
- package/umd/xpath/index.d.ts +3 -3
- package/umd/xpath/match-resolver.d.ts +55 -55
- package/umd/xpath/node-tests/index.d.ts +8 -8
- package/umd/xpath/node-tests/node-test-any.d.ts +6 -6
- package/umd/xpath/node-tests/node-test-comment.d.ts +6 -6
- package/umd/xpath/node-tests/node-test-element-or-attribute.d.ts +6 -6
- package/umd/xpath/node-tests/node-test-name.d.ts +10 -10
- package/umd/xpath/node-tests/node-test-nc.d.ts +9 -9
- package/umd/xpath/node-tests/node-test-pi.d.ts +8 -8
- package/umd/xpath/node-tests/node-test-text.d.ts +6 -6
- package/umd/xpath/node-tests/node-test.d.ts +5 -5
- package/umd/xpath/tokens.d.ts +62 -62
- package/umd/xpath/values/boolean-value.d.ts +11 -11
- package/umd/xpath/values/index.d.ts +5 -5
- package/umd/xpath/values/node-set-value.d.ts +11 -11
- package/umd/xpath/values/node-value.d.ts +7 -7
- package/umd/xpath/values/number-value.d.ts +11 -11
- package/umd/xpath/values/string-value.d.ts +11 -11
- package/umd/xpath/xpath-grammar-rules.d.ts +68 -68
- package/umd/xpath/xpath-token-rule.d.ts +7 -7
- package/umd/xpath/xpath.d.ts +174 -174
- package/umd/xpathdebug.d.ts +2 -2
- package/umd/xslt/index.d.ts +3 -3
- package/umd/xslt/xslt-decimal-format-settings.d.ts +28 -28
- package/umd/xslt/xslt-options.d.ts +7 -7
- package/umd/xslt/xslt-parameter.d.ts +5 -5
- package/umd/xslt/xslt.d.ts +207 -207
- package/umd/xslt-processor.js +1 -15
- package/umd/xslt-processor.js.map +1 -1
- package/xpath/common-function.d.ts +8 -8
- package/xpath/common-function.js +31 -32
- package/xpath/common-function.js.map +1 -1
- package/xpath/expr-context.d.ts +111 -111
- package/xpath/expr-context.js +189 -189
- package/xpath/expr-context.js.map +1 -1
- package/xpath/expressions/binary-expr.d.ts +11 -11
- package/xpath/expressions/binary-expr.js +165 -165
- package/xpath/expressions/binary-expr.js.map +1 -1
- package/xpath/expressions/expression.d.ts +4 -4
- package/xpath/expressions/expression.js +9 -9
- package/xpath/expressions/filter-expr.d.ts +9 -9
- package/xpath/expressions/filter-expr.js +52 -52
- package/xpath/expressions/filter-expr.js.map +1 -1
- package/xpath/expressions/function-call-expr.d.ts +12 -12
- package/xpath/expressions/function-call-expr.js +95 -95
- package/xpath/expressions/function-call-expr.js.map +1 -1
- package/xpath/expressions/index.d.ts +13 -13
- package/xpath/expressions/index.js +29 -29
- package/xpath/expressions/literal-expr.d.ts +7 -7
- package/xpath/expressions/literal-expr.js +33 -33
- package/xpath/expressions/literal-expr.js.map +1 -1
- package/xpath/expressions/location-expr.d.ts +15 -15
- package/xpath/expressions/location-expr.js +98 -98
- package/xpath/expressions/location-expr.js.map +1 -1
- package/xpath/expressions/number-expr.d.ts +7 -7
- package/xpath/expressions/number-expr.js +33 -33
- package/xpath/expressions/number-expr.js.map +1 -1
- package/xpath/expressions/path-expr.d.ts +9 -9
- package/xpath/expressions/path-expr.js +51 -51
- package/xpath/expressions/path-expr.js.map +1 -1
- package/xpath/expressions/predicate-expr.d.ts +8 -8
- package/xpath/expressions/predicate-expr.js +40 -40
- package/xpath/expressions/predicate-expr.js.map +1 -1
- package/xpath/expressions/step-expr.d.ts +25 -25
- package/xpath/expressions/step-expr.js +280 -280
- package/xpath/expressions/step-expr.js.map +1 -1
- package/xpath/expressions/token-expr.d.ts +7 -7
- package/xpath/expressions/token-expr.js +33 -33
- package/xpath/expressions/token-expr.js.map +1 -1
- package/xpath/expressions/unary-minus-expr.d.ts +8 -8
- package/xpath/expressions/unary-minus-expr.js +33 -33
- package/xpath/expressions/unary-minus-expr.js.map +1 -1
- package/xpath/expressions/union-expr.d.ts +9 -9
- package/xpath/expressions/union-expr.js +50 -50
- package/xpath/expressions/union-expr.js.map +1 -1
- package/xpath/expressions/variable-expr.d.ts +7 -7
- package/xpath/expressions/variable-expr.js +32 -32
- package/xpath/expressions/variable-expr.js.map +1 -1
- package/xpath/functions/index.d.ts +2 -2
- package/xpath/functions/index.js +18 -18
- package/xpath/functions/internal-functions.d.ts +2 -2
- package/xpath/functions/internal-functions.js +21 -22
- package/xpath/functions/internal-functions.js.map +1 -1
- package/xpath/functions/non-standard.d.ts +12 -12
- package/xpath/functions/non-standard.js +44 -45
- package/xpath/functions/non-standard.js.map +1 -1
- package/xpath/functions/standard-20.d.ts +5 -5
- package/xpath/functions/standard-20.js +25 -26
- package/xpath/functions/standard-20.js.map +1 -1
- package/xpath/functions/standard.d.ts +40 -40
- package/xpath/functions/standard.js +441 -442
- package/xpath/functions/standard.js.map +1 -1
- package/xpath/grammar-rule-candidate.d.ts +8 -8
- package/xpath/grammar-rule-candidate.js +2 -2
- package/xpath/index.d.ts +3 -3
- package/xpath/index.js +19 -19
- package/xpath/match-resolver.d.ts +55 -55
- package/xpath/match-resolver.js +136 -136
- package/xpath/match-resolver.js.map +1 -1
- package/xpath/node-tests/index.d.ts +8 -8
- package/xpath/node-tests/index.js +17 -17
- package/xpath/node-tests/node-test-any.d.ts +6 -6
- package/xpath/node-tests/node-test-any.js +14 -14
- package/xpath/node-tests/node-test-comment.d.ts +6 -6
- package/xpath/node-tests/node-test-comment.js +14 -14
- package/xpath/node-tests/node-test-element-or-attribute.d.ts +6 -6
- package/xpath/node-tests/node-test-element-or-attribute.js +15 -15
- package/xpath/node-tests/node-test-name.d.ts +10 -10
- package/xpath/node-tests/node-test-name.js +38 -38
- package/xpath/node-tests/node-test-name.js.map +1 -1
- package/xpath/node-tests/node-test-nc.d.ts +9 -9
- package/xpath/node-tests/node-test-nc.js +16 -16
- package/xpath/node-tests/node-test-pi.d.ts +8 -8
- package/xpath/node-tests/node-test-pi.js +16 -16
- package/xpath/node-tests/node-test-text.d.ts +6 -6
- package/xpath/node-tests/node-test-text.js +14 -14
- package/xpath/node-tests/node-test.d.ts +5 -5
- package/xpath/node-tests/node-test.js +2 -2
- package/xpath/tokens.d.ts +62 -62
- package/xpath/tokens.js +300 -300
- package/xpath/values/boolean-value.d.ts +11 -11
- package/xpath/values/boolean-value.js +23 -23
- package/xpath/values/index.d.ts +5 -5
- package/xpath/values/index.js +46 -46
- package/xpath/values/node-set-value.d.ts +11 -11
- package/xpath/values/node-set-value.js +27 -27
- package/xpath/values/node-set-value.js.map +1 -1
- package/xpath/values/node-value.d.ts +7 -7
- package/xpath/values/node-value.js +2 -2
- package/xpath/values/number-value.d.ts +11 -11
- package/xpath/values/number-value.js +23 -23
- package/xpath/values/string-value.d.ts +11 -11
- package/xpath/values/string-value.js +23 -23
- package/xpath/xpath-grammar-rules.d.ts +68 -68
- package/xpath/xpath-grammar-rules.js +74 -74
- package/xpath/xpath-token-rule.d.ts +7 -7
- package/xpath/xpath-token-rule.js +2 -2
- package/xpath/xpath.d.ts +174 -174
- package/xpath/xpath.js +911 -911
- package/xpath/xpath.js.map +1 -1
- package/xpathdebug.d.ts +2 -2
- package/xpathdebug.js +187 -187
- package/xpathdebug.js.map +1 -1
- package/xslt/index.d.ts +3 -3
- package/xslt/index.js +19 -19
- package/xslt/xslt-decimal-format-settings.d.ts +28 -28
- package/xslt/xslt-decimal-format-settings.js +2 -2
- package/xslt/xslt-options.d.ts +7 -7
- package/xslt/xslt-options.js +2 -2
- package/xslt/xslt-parameter.d.ts +5 -5
- package/xslt/xslt-parameter.js +2 -2
- package/xslt/xslt.d.ts +207 -207
- package/xslt/xslt.js +1135 -1126
- package/xslt/xslt.js.map +1 -1
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* According to https://www.w3schools.com/xml/ref_xsl_el_decimal-format.asp:
|
|
3
|
-
*
|
|
4
|
-
* @property {string} name: Optional. Specifies a name for this format.
|
|
5
|
-
* @property {string} decimalSeparator: Optional. Specifies the decimal point character. Default is ".".
|
|
6
|
-
* @property {string} groupingSeparator: Optional. Specifies the thousands separator character. Default is ",".
|
|
7
|
-
* @property {string} infinity: Optional. Specifies the string used to represent infinity. Default is "Infinity".
|
|
8
|
-
* @property {string} minusSign: Optional. Specifies the character to represent negative numbers. Default is "-".
|
|
9
|
-
* @property {string} naN: Optional. Specifies the string used when the value is not a number". Default is "NaN".
|
|
10
|
-
* @property {string} percent: Optional. Specifies the percentage sign character. Default is "%".
|
|
11
|
-
* @property {string} perMille: Optional. Specifies the per thousand sign character. Default is "‰".
|
|
12
|
-
* @property {string} zeroDigit: Optional. Specifies the digit zero character. Default is "0".
|
|
13
|
-
* @property {string} digit: Optional. Specifies the character used to indicate a place where a digit is required. Default is #.
|
|
14
|
-
* @property {string} patternSeparator: Optional. Specifies the character used to separate positive and negative subpatterns in a format pattern. Default is ";".
|
|
15
|
-
*/
|
|
16
|
-
export type XsltDecimalFormatSettings = {
|
|
17
|
-
name?: string;
|
|
18
|
-
decimalSeparator: string;
|
|
19
|
-
groupingSeparator: string;
|
|
20
|
-
infinity: string;
|
|
21
|
-
minusSign: string;
|
|
22
|
-
naN: string;
|
|
23
|
-
percent: string;
|
|
24
|
-
perMille: string;
|
|
25
|
-
zeroDigit: string;
|
|
26
|
-
digit: string;
|
|
27
|
-
patternSeparator: string;
|
|
28
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* According to https://www.w3schools.com/xml/ref_xsl_el_decimal-format.asp:
|
|
3
|
+
*
|
|
4
|
+
* @property {string} name: Optional. Specifies a name for this format.
|
|
5
|
+
* @property {string} decimalSeparator: Optional. Specifies the decimal point character. Default is ".".
|
|
6
|
+
* @property {string} groupingSeparator: Optional. Specifies the thousands separator character. Default is ",".
|
|
7
|
+
* @property {string} infinity: Optional. Specifies the string used to represent infinity. Default is "Infinity".
|
|
8
|
+
* @property {string} minusSign: Optional. Specifies the character to represent negative numbers. Default is "-".
|
|
9
|
+
* @property {string} naN: Optional. Specifies the string used when the value is not a number". Default is "NaN".
|
|
10
|
+
* @property {string} percent: Optional. Specifies the percentage sign character. Default is "%".
|
|
11
|
+
* @property {string} perMille: Optional. Specifies the per thousand sign character. Default is "‰".
|
|
12
|
+
* @property {string} zeroDigit: Optional. Specifies the digit zero character. Default is "0".
|
|
13
|
+
* @property {string} digit: Optional. Specifies the character used to indicate a place where a digit is required. Default is #.
|
|
14
|
+
* @property {string} patternSeparator: Optional. Specifies the character used to separate positive and negative subpatterns in a format pattern. Default is ";".
|
|
15
|
+
*/
|
|
16
|
+
export type XsltDecimalFormatSettings = {
|
|
17
|
+
name?: string;
|
|
18
|
+
decimalSeparator: string;
|
|
19
|
+
groupingSeparator: string;
|
|
20
|
+
infinity: string;
|
|
21
|
+
minusSign: string;
|
|
22
|
+
naN: string;
|
|
23
|
+
percent: string;
|
|
24
|
+
perMille: string;
|
|
25
|
+
zeroDigit: string;
|
|
26
|
+
digit: string;
|
|
27
|
+
patternSeparator: string;
|
|
28
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=xslt-decimal-format-settings.js.map
|
package/xslt/xslt-options.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { XsltParameter } from "./xslt-parameter";
|
|
2
|
-
export type XsltOptions = {
|
|
3
|
-
cData: boolean;
|
|
4
|
-
escape: boolean;
|
|
5
|
-
selfClosingTags: boolean;
|
|
6
|
-
parameters?: XsltParameter[];
|
|
7
|
-
};
|
|
1
|
+
import { XsltParameter } from "./xslt-parameter";
|
|
2
|
+
export type XsltOptions = {
|
|
3
|
+
cData: boolean;
|
|
4
|
+
escape: boolean;
|
|
5
|
+
selfClosingTags: boolean;
|
|
6
|
+
parameters?: XsltParameter[];
|
|
7
|
+
};
|
package/xslt/xslt-options.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=xslt-options.js.map
|
package/xslt/xslt-parameter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type XsltParameter = {
|
|
2
|
-
name: string;
|
|
3
|
-
namespaceUri?: string;
|
|
4
|
-
value: any;
|
|
5
|
-
};
|
|
1
|
+
export type XsltParameter = {
|
|
2
|
+
name: string;
|
|
3
|
+
namespaceUri?: string;
|
|
4
|
+
value: any;
|
|
5
|
+
};
|
package/xslt/xslt-parameter.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=xslt-parameter.js.map
|
package/xslt/xslt.d.ts
CHANGED
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
import { XDocument, XNode, XmlParser } from '../dom';
|
|
2
|
-
import { ExprContext, XPath } from '../xpath';
|
|
3
|
-
import { XsltOptions } from './xslt-options';
|
|
4
|
-
import { XsltDecimalFormatSettings } from './xslt-decimal-format-settings';
|
|
5
|
-
import { MatchResolver } from '../xpath/match-resolver';
|
|
6
|
-
/**
|
|
7
|
-
* The main class for XSL-T processing. The implementation is NOT
|
|
8
|
-
* complete; some xsl element are left out.
|
|
9
|
-
*
|
|
10
|
-
* References:
|
|
11
|
-
*
|
|
12
|
-
* [XSLT] XSL-T Specification
|
|
13
|
-
* <http://www.w3.org/TR/1999/REC-xslt-19991116>.
|
|
14
|
-
*
|
|
15
|
-
* [ECMA] ECMAScript Language Specification
|
|
16
|
-
* <http://www.ecma-international.org/publications/standards/Ecma-262.htm>.
|
|
17
|
-
*
|
|
18
|
-
* The XSL processor API has one entry point, the function
|
|
19
|
-
* xsltProcessContext(). It receives as arguments the starting point in the
|
|
20
|
-
* input document as an XPath expression context, the DOM root node of
|
|
21
|
-
* the XSL-T stylesheet, and a DOM node that receives the output.
|
|
22
|
-
*
|
|
23
|
-
* NOTE: Actually, XSL-T processing according to the specification is
|
|
24
|
-
* defined as operation on text documents, not as operation on DOM
|
|
25
|
-
* trees. So, strictly speaking, this implementation is not an XSL-T
|
|
26
|
-
* processor, but the processing engine that needs to be complemented
|
|
27
|
-
* by an XML parser and serializer in order to be complete. Those two
|
|
28
|
-
* are found in the `dom` folder.
|
|
29
|
-
*/
|
|
30
|
-
export declare class Xslt {
|
|
31
|
-
xPath: XPath;
|
|
32
|
-
xmlParser: XmlParser;
|
|
33
|
-
matchResolver: MatchResolver;
|
|
34
|
-
options: XsltOptions;
|
|
35
|
-
decimalFormatSettings: XsltDecimalFormatSettings;
|
|
36
|
-
outputDocument: XDocument;
|
|
37
|
-
outputMethod: 'xml' | 'html' | 'text' | 'name';
|
|
38
|
-
outputOmitXmlDeclaration: string;
|
|
39
|
-
version: string;
|
|
40
|
-
constructor(options?: Partial<XsltOptions>);
|
|
41
|
-
/**
|
|
42
|
-
* The exported entry point of the XSL-T processor.
|
|
43
|
-
* @param xmlDoc The input document root, as DOM node.
|
|
44
|
-
* @param stylesheet The stylesheet document root, as DOM node.
|
|
45
|
-
* @returns the processed document, as XML text in a string.
|
|
46
|
-
*/
|
|
47
|
-
xsltProcess(xmlDoc: XDocument, stylesheet: XDocument): Promise<string>;
|
|
48
|
-
/**
|
|
49
|
-
* The main entry point of the XSL-T processor, as explained on the top of the file.
|
|
50
|
-
* @param context The input document root, as XPath `ExprContext`.
|
|
51
|
-
* @param template The stylesheet document root, as DOM node.
|
|
52
|
-
* @param output If set, the output where the transformation should occur.
|
|
53
|
-
*/
|
|
54
|
-
protected xsltProcessContext(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Implements `xsl:apply-templates`.
|
|
57
|
-
* @param context The Expression Context.
|
|
58
|
-
* @param template The template.
|
|
59
|
-
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
60
|
-
* @protected
|
|
61
|
-
*/
|
|
62
|
-
protected xsltApplyTemplates(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Implements `xsl:attribute`.
|
|
65
|
-
* @param context The Expression Context.
|
|
66
|
-
* @param template The template.
|
|
67
|
-
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
68
|
-
* @protected
|
|
69
|
-
*/
|
|
70
|
-
protected xsltAttribute(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Implements `xsl:choose`, its child nodes `xsl:when`, and
|
|
73
|
-
* `xsl:otherwise`.
|
|
74
|
-
* @param context The Expression Context.
|
|
75
|
-
* @param template The template.
|
|
76
|
-
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
77
|
-
*/
|
|
78
|
-
protected xsltChoose(context: ExprContext, template: XNode, output
|
|
79
|
-
/**
|
|
80
|
-
* Implements `xsl:copy` for all node types.
|
|
81
|
-
* @param {XNode} destination the node being copied to, part of output document.
|
|
82
|
-
* @param {XNode} source the node being copied, part in input document.
|
|
83
|
-
* @returns {XNode|null} If an element node was created, the element node. Otherwise, null.
|
|
84
|
-
*/
|
|
85
|
-
protected xsltCopy(destination: XNode, source: XNode): XNode;
|
|
86
|
-
/**
|
|
87
|
-
* Implements `xsl:copy-of` for node-set values of the select
|
|
88
|
-
* expression. Recurses down the source node tree, which is part of
|
|
89
|
-
* the input document.
|
|
90
|
-
* @param {XNode} destination the node being copied to, part of output document.
|
|
91
|
-
* @param {XNode} source the node being copied, part in input document.
|
|
92
|
-
*/
|
|
93
|
-
protected xsltCopyOf(destination: XNode, source: XNode): void;
|
|
94
|
-
/**
|
|
95
|
-
* Implements `xsl:for-each`.
|
|
96
|
-
* @param context The Expression Context.
|
|
97
|
-
* @param template The template.
|
|
98
|
-
* @param output The output.
|
|
99
|
-
*/
|
|
100
|
-
protected xsltForEach(context: ExprContext, template: XNode, output: XNode): Promise<void>;
|
|
101
|
-
/**
|
|
102
|
-
* Implements `xsl:include`.
|
|
103
|
-
* @param context The Expression Context.
|
|
104
|
-
* @param template The template.
|
|
105
|
-
* @param output The output.
|
|
106
|
-
*/
|
|
107
|
-
protected xsltInclude(context: ExprContext, template: XNode, output: XNode): Promise<void>;
|
|
108
|
-
/**
|
|
109
|
-
* Orders the current node list in the input context according to the
|
|
110
|
-
* sort order specified by xsl:sort child nodes of the current
|
|
111
|
-
* template node. This happens before the operation specified by the
|
|
112
|
-
* current template node is executed.
|
|
113
|
-
* @param context The expression context.
|
|
114
|
-
* @param template The template node.
|
|
115
|
-
* @todo case-order is not implemented.
|
|
116
|
-
*/
|
|
117
|
-
protected xsltSort(context: ExprContext, template: XNode): void;
|
|
118
|
-
/**
|
|
119
|
-
* Implements `<xsl:stylesheet>` and `<xsl:transform>`, and its corresponding
|
|
120
|
-
* validations.
|
|
121
|
-
* @param template The `<xsl:stylesheet>` or `<xsl:transform>` node.
|
|
122
|
-
* @param context The Expression Context.
|
|
123
|
-
* @param output The output XML.
|
|
124
|
-
*/
|
|
125
|
-
protected xsltTransformOrStylesheet(template: XNode, context: ExprContext, output: XNode): Promise<void>;
|
|
126
|
-
/**
|
|
127
|
-
* Evaluates a variable or parameter and set it in the current input
|
|
128
|
-
* context. Implements `xsl:variable`, `xsl:param`, and `xsl:with-param`.
|
|
129
|
-
*
|
|
130
|
-
* @param context The expression context.
|
|
131
|
-
* @param template The template node.
|
|
132
|
-
* @param override flag that defines if the value computed here
|
|
133
|
-
* overrides the one already in the input context if that is the
|
|
134
|
-
* case. I.e. decides if this is a default value or a local
|
|
135
|
-
* value. `xsl:variable` and `xsl:with-param` override; `xsl:param` doesn't.
|
|
136
|
-
*/
|
|
137
|
-
protected xsltVariable(context: ExprContext, template: XNode, override: boolean): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Traverses the template node tree. Calls the main processing
|
|
140
|
-
* function with the current input context for every child node of the
|
|
141
|
-
* current template node.
|
|
142
|
-
* @param context Normally the Expression Context.
|
|
143
|
-
* @param template The XSL-T definition.
|
|
144
|
-
* @param output If set, the output where the transformation should occur.
|
|
145
|
-
*/
|
|
146
|
-
protected xsltChildNodes(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
* This logic is used in two different places:
|
|
149
|
-
* - `xsltPassThrough`, if the template asks this library to write a text node;
|
|
150
|
-
* - `xsltProcessContext`, `apply-templates` operation, when the current node is text.
|
|
151
|
-
* @param context The Expression Context.
|
|
152
|
-
* @param template The template, that contains the node value to be written.
|
|
153
|
-
* @param output The output.
|
|
154
|
-
*/
|
|
155
|
-
private commonLogicTextNode;
|
|
156
|
-
/**
|
|
157
|
-
* Passes template text to the output. The current template node does
|
|
158
|
-
* not specify an XSL-T operation and therefore is appended to the
|
|
159
|
-
* output with all its attributes. Then continues traversing the
|
|
160
|
-
* template node tree.
|
|
161
|
-
* @param context The Expression Context.
|
|
162
|
-
* @param template The XSLT stylesheet or transformation.
|
|
163
|
-
* @param output The output.
|
|
164
|
-
*/
|
|
165
|
-
protected xsltPassThrough(context: ExprContext, template: XNode, output: XNode): Promise<void>;
|
|
166
|
-
/**
|
|
167
|
-
* Determines if a text node in the XSLT template document is to be
|
|
168
|
-
* stripped according to XSLT whitespace stripping rules.
|
|
169
|
-
* @see [XSLT], section 3.4.
|
|
170
|
-
* @param template The XSLT template.
|
|
171
|
-
* @returns TODO
|
|
172
|
-
* @todo Whitespace stripping on the input document is
|
|
173
|
-
* currently not implemented.
|
|
174
|
-
*/
|
|
175
|
-
protected xsltPassText(template: XNode): boolean;
|
|
176
|
-
protected findAttributeInContext(attributeName: string, context: ExprContext): XNode;
|
|
177
|
-
/**
|
|
178
|
-
* Evaluates an XSL-T attribute value template. Attribute value
|
|
179
|
-
* templates are attributes on XSL-T elements that contain XPath
|
|
180
|
-
* expressions in braces {}. The XSL-T expressions are evaluated in
|
|
181
|
-
* the current input context.
|
|
182
|
-
* @param value TODO
|
|
183
|
-
* @param context TODO
|
|
184
|
-
* @returns TODO
|
|
185
|
-
*/
|
|
186
|
-
protected xsltAttributeValue(value: any, context: ExprContext): any;
|
|
187
|
-
/**
|
|
188
|
-
* Evaluates an XPath expression in the current input context as a
|
|
189
|
-
* match.
|
|
190
|
-
* @see [XSLT] section 5.2, paragraph 1
|
|
191
|
-
* @param match TODO
|
|
192
|
-
* @param context The Expression Context.
|
|
193
|
-
* @param axis The XPath axis. Used when the match does not start with the parent.
|
|
194
|
-
* @returns {XNode[]} A list of the found nodes.
|
|
195
|
-
*/
|
|
196
|
-
protected xsltMatch(match: string, context: ExprContext, axis?: string): XNode[];
|
|
197
|
-
/**
|
|
198
|
-
* Sets parameters defined by xsl:with-param child nodes of the
|
|
199
|
-
* current template node, in the current input context. This happens
|
|
200
|
-
* before the operation specified by the current template node is
|
|
201
|
-
* executed.
|
|
202
|
-
* @param context The Expression Context.
|
|
203
|
-
* @param template The template node.
|
|
204
|
-
*/
|
|
205
|
-
protected xsltWithParam(context: ExprContext, template: XNode): Promise<void>;
|
|
206
|
-
protected isXsltElement(element: any, opt_wantedName?: string): boolean;
|
|
207
|
-
}
|
|
1
|
+
import { XDocument, XNode, XmlParser } from '../dom';
|
|
2
|
+
import { ExprContext, XPath } from '../xpath';
|
|
3
|
+
import { XsltOptions } from './xslt-options';
|
|
4
|
+
import { XsltDecimalFormatSettings } from './xslt-decimal-format-settings';
|
|
5
|
+
import { MatchResolver } from '../xpath/match-resolver';
|
|
6
|
+
/**
|
|
7
|
+
* The main class for XSL-T processing. The implementation is NOT
|
|
8
|
+
* complete; some xsl element are left out.
|
|
9
|
+
*
|
|
10
|
+
* References:
|
|
11
|
+
*
|
|
12
|
+
* [XSLT] XSL-T Specification
|
|
13
|
+
* <http://www.w3.org/TR/1999/REC-xslt-19991116>.
|
|
14
|
+
*
|
|
15
|
+
* [ECMA] ECMAScript Language Specification
|
|
16
|
+
* <http://www.ecma-international.org/publications/standards/Ecma-262.htm>.
|
|
17
|
+
*
|
|
18
|
+
* The XSL processor API has one entry point, the function
|
|
19
|
+
* xsltProcessContext(). It receives as arguments the starting point in the
|
|
20
|
+
* input document as an XPath expression context, the DOM root node of
|
|
21
|
+
* the XSL-T stylesheet, and a DOM node that receives the output.
|
|
22
|
+
*
|
|
23
|
+
* NOTE: Actually, XSL-T processing according to the specification is
|
|
24
|
+
* defined as operation on text documents, not as operation on DOM
|
|
25
|
+
* trees. So, strictly speaking, this implementation is not an XSL-T
|
|
26
|
+
* processor, but the processing engine that needs to be complemented
|
|
27
|
+
* by an XML parser and serializer in order to be complete. Those two
|
|
28
|
+
* are found in the `dom` folder.
|
|
29
|
+
*/
|
|
30
|
+
export declare class Xslt {
|
|
31
|
+
xPath: XPath;
|
|
32
|
+
xmlParser: XmlParser;
|
|
33
|
+
matchResolver: MatchResolver;
|
|
34
|
+
options: XsltOptions;
|
|
35
|
+
decimalFormatSettings: XsltDecimalFormatSettings;
|
|
36
|
+
outputDocument: XDocument;
|
|
37
|
+
outputMethod: 'xml' | 'html' | 'text' | 'name';
|
|
38
|
+
outputOmitXmlDeclaration: string;
|
|
39
|
+
version: string;
|
|
40
|
+
constructor(options?: Partial<XsltOptions>);
|
|
41
|
+
/**
|
|
42
|
+
* The exported entry point of the XSL-T processor.
|
|
43
|
+
* @param xmlDoc The input document root, as DOM node.
|
|
44
|
+
* @param stylesheet The stylesheet document root, as DOM node.
|
|
45
|
+
* @returns the processed document, as XML text in a string.
|
|
46
|
+
*/
|
|
47
|
+
xsltProcess(xmlDoc: XDocument, stylesheet: XDocument): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* The main entry point of the XSL-T processor, as explained on the top of the file.
|
|
50
|
+
* @param context The input document root, as XPath `ExprContext`.
|
|
51
|
+
* @param template The stylesheet document root, as DOM node.
|
|
52
|
+
* @param output If set, the output where the transformation should occur.
|
|
53
|
+
*/
|
|
54
|
+
protected xsltProcessContext(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Implements `xsl:apply-templates`.
|
|
57
|
+
* @param context The Expression Context.
|
|
58
|
+
* @param template The template.
|
|
59
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
60
|
+
* @protected
|
|
61
|
+
*/
|
|
62
|
+
protected xsltApplyTemplates(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Implements `xsl:attribute`.
|
|
65
|
+
* @param context The Expression Context.
|
|
66
|
+
* @param template The template.
|
|
67
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
68
|
+
* @protected
|
|
69
|
+
*/
|
|
70
|
+
protected xsltAttribute(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Implements `xsl:choose`, its child nodes `xsl:when`, and
|
|
73
|
+
* `xsl:otherwise`.
|
|
74
|
+
* @param context The Expression Context.
|
|
75
|
+
* @param template The template.
|
|
76
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
77
|
+
*/
|
|
78
|
+
protected xsltChoose(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Implements `xsl:copy` for all node types.
|
|
81
|
+
* @param {XNode} destination the node being copied to, part of output document.
|
|
82
|
+
* @param {XNode} source the node being copied, part in input document.
|
|
83
|
+
* @returns {XNode|null} If an element node was created, the element node. Otherwise, null.
|
|
84
|
+
*/
|
|
85
|
+
protected xsltCopy(destination: XNode, source: XNode): XNode;
|
|
86
|
+
/**
|
|
87
|
+
* Implements `xsl:copy-of` for node-set values of the select
|
|
88
|
+
* expression. Recurses down the source node tree, which is part of
|
|
89
|
+
* the input document.
|
|
90
|
+
* @param {XNode} destination the node being copied to, part of output document.
|
|
91
|
+
* @param {XNode} source the node being copied, part in input document.
|
|
92
|
+
*/
|
|
93
|
+
protected xsltCopyOf(destination: XNode, source: XNode): void;
|
|
94
|
+
/**
|
|
95
|
+
* Implements `xsl:for-each`.
|
|
96
|
+
* @param context The Expression Context.
|
|
97
|
+
* @param template The template.
|
|
98
|
+
* @param output The output.
|
|
99
|
+
*/
|
|
100
|
+
protected xsltForEach(context: ExprContext, template: XNode, output: XNode): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Implements `xsl:include`.
|
|
103
|
+
* @param context The Expression Context.
|
|
104
|
+
* @param template The template.
|
|
105
|
+
* @param output The output.
|
|
106
|
+
*/
|
|
107
|
+
protected xsltInclude(context: ExprContext, template: XNode, output: XNode): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Orders the current node list in the input context according to the
|
|
110
|
+
* sort order specified by xsl:sort child nodes of the current
|
|
111
|
+
* template node. This happens before the operation specified by the
|
|
112
|
+
* current template node is executed.
|
|
113
|
+
* @param context The expression context.
|
|
114
|
+
* @param template The template node.
|
|
115
|
+
* @todo case-order is not implemented.
|
|
116
|
+
*/
|
|
117
|
+
protected xsltSort(context: ExprContext, template: XNode): void;
|
|
118
|
+
/**
|
|
119
|
+
* Implements `<xsl:stylesheet>` and `<xsl:transform>`, and its corresponding
|
|
120
|
+
* validations.
|
|
121
|
+
* @param template The `<xsl:stylesheet>` or `<xsl:transform>` node.
|
|
122
|
+
* @param context The Expression Context.
|
|
123
|
+
* @param output The output XML.
|
|
124
|
+
*/
|
|
125
|
+
protected xsltTransformOrStylesheet(template: XNode, context: ExprContext, output: XNode): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Evaluates a variable or parameter and set it in the current input
|
|
128
|
+
* context. Implements `xsl:variable`, `xsl:param`, and `xsl:with-param`.
|
|
129
|
+
*
|
|
130
|
+
* @param context The expression context.
|
|
131
|
+
* @param template The template node.
|
|
132
|
+
* @param override flag that defines if the value computed here
|
|
133
|
+
* overrides the one already in the input context if that is the
|
|
134
|
+
* case. I.e. decides if this is a default value or a local
|
|
135
|
+
* value. `xsl:variable` and `xsl:with-param` override; `xsl:param` doesn't.
|
|
136
|
+
*/
|
|
137
|
+
protected xsltVariable(context: ExprContext, template: XNode, override: boolean): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Traverses the template node tree. Calls the main processing
|
|
140
|
+
* function with the current input context for every child node of the
|
|
141
|
+
* current template node.
|
|
142
|
+
* @param context Normally the Expression Context.
|
|
143
|
+
* @param template The XSL-T definition.
|
|
144
|
+
* @param output If set, the output where the transformation should occur.
|
|
145
|
+
*/
|
|
146
|
+
protected xsltChildNodes(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* This logic is used in two different places:
|
|
149
|
+
* - `xsltPassThrough`, if the template asks this library to write a text node;
|
|
150
|
+
* - `xsltProcessContext`, `apply-templates` operation, when the current node is text.
|
|
151
|
+
* @param context The Expression Context.
|
|
152
|
+
* @param template The template, that contains the node value to be written.
|
|
153
|
+
* @param output The output.
|
|
154
|
+
*/
|
|
155
|
+
private commonLogicTextNode;
|
|
156
|
+
/**
|
|
157
|
+
* Passes template text to the output. The current template node does
|
|
158
|
+
* not specify an XSL-T operation and therefore is appended to the
|
|
159
|
+
* output with all its attributes. Then continues traversing the
|
|
160
|
+
* template node tree.
|
|
161
|
+
* @param context The Expression Context.
|
|
162
|
+
* @param template The XSLT stylesheet or transformation.
|
|
163
|
+
* @param output The output.
|
|
164
|
+
*/
|
|
165
|
+
protected xsltPassThrough(context: ExprContext, template: XNode, output: XNode): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Determines if a text node in the XSLT template document is to be
|
|
168
|
+
* stripped according to XSLT whitespace stripping rules.
|
|
169
|
+
* @see [XSLT], section 3.4.
|
|
170
|
+
* @param template The XSLT template.
|
|
171
|
+
* @returns TODO
|
|
172
|
+
* @todo Whitespace stripping on the input document is
|
|
173
|
+
* currently not implemented.
|
|
174
|
+
*/
|
|
175
|
+
protected xsltPassText(template: XNode): boolean;
|
|
176
|
+
protected findAttributeInContext(attributeName: string, context: ExprContext): XNode;
|
|
177
|
+
/**
|
|
178
|
+
* Evaluates an XSL-T attribute value template. Attribute value
|
|
179
|
+
* templates are attributes on XSL-T elements that contain XPath
|
|
180
|
+
* expressions in braces {}. The XSL-T expressions are evaluated in
|
|
181
|
+
* the current input context.
|
|
182
|
+
* @param value TODO
|
|
183
|
+
* @param context TODO
|
|
184
|
+
* @returns TODO
|
|
185
|
+
*/
|
|
186
|
+
protected xsltAttributeValue(value: any, context: ExprContext): any;
|
|
187
|
+
/**
|
|
188
|
+
* Evaluates an XPath expression in the current input context as a
|
|
189
|
+
* match.
|
|
190
|
+
* @see [XSLT] section 5.2, paragraph 1
|
|
191
|
+
* @param match TODO
|
|
192
|
+
* @param context The Expression Context.
|
|
193
|
+
* @param axis The XPath axis. Used when the match does not start with the parent.
|
|
194
|
+
* @returns {XNode[]} A list of the found nodes.
|
|
195
|
+
*/
|
|
196
|
+
protected xsltMatch(match: string, context: ExprContext, axis?: string): XNode[];
|
|
197
|
+
/**
|
|
198
|
+
* Sets parameters defined by xsl:with-param child nodes of the
|
|
199
|
+
* current template node, in the current input context. This happens
|
|
200
|
+
* before the operation specified by the current template node is
|
|
201
|
+
* executed.
|
|
202
|
+
* @param context The Expression Context.
|
|
203
|
+
* @param template The template node.
|
|
204
|
+
*/
|
|
205
|
+
protected xsltWithParam(context: ExprContext, template: XNode): Promise<void>;
|
|
206
|
+
protected isXsltElement(element: any, opt_wantedName?: string): boolean;
|
|
207
|
+
}
|