xslt-processor 3.4.0 → 4.0.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/index.d.mts +817 -0
- package/index.d.ts +817 -4
- package/index.js +4467 -12
- package/index.js.map +1 -1
- package/index.mjs +4431 -0
- package/index.mjs.map +1 -0
- package/package.json +23 -18
- package/umd/xslt-processor.global.js +9 -0
- package/umd/xslt-processor.global.js.map +1 -0
- package/constants.d.ts +0 -12
- package/constants.js +0 -17
- package/constants.js.map +0 -1
- package/dom/functions.d.ts +0 -14
- package/dom/functions.js +0 -57
- package/dom/functions.js.map +0 -1
- package/dom/index.d.ts +0 -7
- package/dom/index.js +0 -24
- package/dom/index.js.map +0 -1
- package/dom/util.d.ts +0 -7
- package/dom/util.js +0 -43
- package/dom/util.js.map +0 -1
- package/dom/xbrowser-node.d.ts +0 -9
- package/dom/xbrowser-node.js +0 -32
- package/dom/xbrowser-node.js.map +0 -1
- package/dom/xdocument.d.ts +0 -16
- package/dom/xdocument.js +0 -74
- package/dom/xdocument.js.map +0 -1
- package/dom/xml-functions.d.ts +0 -73
- package/dom/xml-functions.js +0 -402
- package/dom/xml-functions.js.map +0 -1
- package/dom/xml-output-options.d.ts +0 -6
- package/dom/xml-output-options.js +0 -3
- package/dom/xml-output-options.js.map +0 -1
- package/dom/xml-parser.d.ts +0 -47
- package/dom/xml-parser.js +0 -308
- package/dom/xml-parser.js.map +0 -1
- package/dom/xmltoken.d.ts +0 -12
- package/dom/xmltoken.js +0 -102
- package/dom/xmltoken.js.map +0 -1
- package/dom/xnode.d.ts +0 -73
- package/dom/xnode.js +0 -451
- package/dom/xnode.js.map +0 -1
- package/test-without-jest.d.ts +0 -1
- package/test-without-jest.js +0 -63
- package/test-without-jest.js.map +0 -1
- package/umd/constants.d.ts +0 -12
- package/umd/dom/functions.d.ts +0 -14
- package/umd/dom/index.d.ts +0 -7
- package/umd/dom/util.d.ts +0 -7
- package/umd/dom/xbrowser-node.d.ts +0 -9
- package/umd/dom/xdocument.d.ts +0 -16
- package/umd/dom/xml-functions.d.ts +0 -73
- package/umd/dom/xml-output-options.d.ts +0 -6
- package/umd/dom/xml-parser.d.ts +0 -47
- package/umd/dom/xmltoken.d.ts +0 -12
- package/umd/dom/xnode.d.ts +0 -73
- package/umd/index.d.ts +0 -4
- package/umd/test-without-jest.d.ts +0 -1
- package/umd/xpath/common-function.d.ts +0 -8
- package/umd/xpath/expr-context.d.ts +0 -116
- package/umd/xpath/expressions/binary-expr.d.ts +0 -11
- package/umd/xpath/expressions/expression.d.ts +0 -4
- package/umd/xpath/expressions/filter-expr.d.ts +0 -9
- package/umd/xpath/expressions/function-call-expr.d.ts +0 -12
- package/umd/xpath/expressions/index.d.ts +0 -13
- package/umd/xpath/expressions/literal-expr.d.ts +0 -7
- package/umd/xpath/expressions/location-expr.d.ts +0 -15
- package/umd/xpath/expressions/number-expr.d.ts +0 -7
- package/umd/xpath/expressions/path-expr.d.ts +0 -9
- package/umd/xpath/expressions/predicate-expr.d.ts +0 -8
- package/umd/xpath/expressions/step-expr.d.ts +0 -25
- package/umd/xpath/expressions/token-expr.d.ts +0 -7
- package/umd/xpath/expressions/unary-minus-expr.d.ts +0 -8
- package/umd/xpath/expressions/union-expr.d.ts +0 -9
- package/umd/xpath/expressions/variable-expr.d.ts +0 -7
- package/umd/xpath/functions/index.d.ts +0 -4
- package/umd/xpath/functions/internal-functions.d.ts +0 -2
- package/umd/xpath/functions/non-standard.d.ts +0 -12
- package/umd/xpath/functions/standard-20.d.ts +0 -5
- package/umd/xpath/functions/standard.d.ts +0 -40
- package/umd/xpath/functions/xslt-specific.d.ts +0 -3
- package/umd/xpath/grammar-rule-candidate.d.ts +0 -8
- package/umd/xpath/index.d.ts +0 -3
- package/umd/xpath/match-resolver.d.ts +0 -55
- package/umd/xpath/node-tests/index.d.ts +0 -8
- package/umd/xpath/node-tests/node-test-any.d.ts +0 -6
- package/umd/xpath/node-tests/node-test-comment.d.ts +0 -6
- package/umd/xpath/node-tests/node-test-element-or-attribute.d.ts +0 -6
- package/umd/xpath/node-tests/node-test-name.d.ts +0 -10
- package/umd/xpath/node-tests/node-test-nc.d.ts +0 -9
- package/umd/xpath/node-tests/node-test-pi.d.ts +0 -8
- package/umd/xpath/node-tests/node-test-text.d.ts +0 -6
- package/umd/xpath/node-tests/node-test.d.ts +0 -5
- package/umd/xpath/tokens.d.ts +0 -62
- package/umd/xpath/values/boolean-value.d.ts +0 -11
- package/umd/xpath/values/index.d.ts +0 -5
- package/umd/xpath/values/node-set-value.d.ts +0 -11
- package/umd/xpath/values/node-value.d.ts +0 -7
- package/umd/xpath/values/number-value.d.ts +0 -11
- package/umd/xpath/values/string-value.d.ts +0 -11
- package/umd/xpath/xpath-grammar-rules.d.ts +0 -68
- package/umd/xpath/xpath-token-rule.d.ts +0 -7
- package/umd/xpath/xpath.d.ts +0 -174
- package/umd/xpathdebug.d.ts +0 -2
- package/umd/xslt/index.d.ts +0 -3
- package/umd/xslt/xslt-decimal-format-settings.d.ts +0 -28
- package/umd/xslt/xslt-options.d.ts +0 -7
- package/umd/xslt/xslt-parameter.d.ts +0 -5
- package/umd/xslt/xslt.d.ts +0 -275
- package/umd/xslt-processor.js +0 -2
- package/umd/xslt-processor.js.map +0 -1
- package/xpath/common-function.d.ts +0 -8
- package/xpath/common-function.js +0 -32
- package/xpath/common-function.js.map +0 -1
- package/xpath/expr-context.d.ts +0 -116
- package/xpath/expr-context.js +0 -191
- package/xpath/expr-context.js.map +0 -1
- package/xpath/expressions/binary-expr.d.ts +0 -11
- package/xpath/expressions/binary-expr.js +0 -166
- package/xpath/expressions/binary-expr.js.map +0 -1
- package/xpath/expressions/expression.d.ts +0 -4
- package/xpath/expressions/expression.js +0 -10
- package/xpath/expressions/expression.js.map +0 -1
- package/xpath/expressions/filter-expr.d.ts +0 -9
- package/xpath/expressions/filter-expr.js +0 -53
- package/xpath/expressions/filter-expr.js.map +0 -1
- package/xpath/expressions/function-call-expr.d.ts +0 -12
- package/xpath/expressions/function-call-expr.js +0 -97
- package/xpath/expressions/function-call-expr.js.map +0 -1
- package/xpath/expressions/index.d.ts +0 -13
- package/xpath/expressions/index.js +0 -30
- package/xpath/expressions/index.js.map +0 -1
- package/xpath/expressions/literal-expr.d.ts +0 -7
- package/xpath/expressions/literal-expr.js +0 -34
- package/xpath/expressions/literal-expr.js.map +0 -1
- package/xpath/expressions/location-expr.d.ts +0 -15
- package/xpath/expressions/location-expr.js +0 -99
- package/xpath/expressions/location-expr.js.map +0 -1
- package/xpath/expressions/number-expr.d.ts +0 -7
- package/xpath/expressions/number-expr.js +0 -34
- package/xpath/expressions/number-expr.js.map +0 -1
- package/xpath/expressions/path-expr.d.ts +0 -9
- package/xpath/expressions/path-expr.js +0 -52
- package/xpath/expressions/path-expr.js.map +0 -1
- package/xpath/expressions/predicate-expr.d.ts +0 -8
- package/xpath/expressions/predicate-expr.js +0 -41
- package/xpath/expressions/predicate-expr.js.map +0 -1
- package/xpath/expressions/step-expr.d.ts +0 -25
- package/xpath/expressions/step-expr.js +0 -281
- package/xpath/expressions/step-expr.js.map +0 -1
- package/xpath/expressions/token-expr.d.ts +0 -7
- package/xpath/expressions/token-expr.js +0 -34
- package/xpath/expressions/token-expr.js.map +0 -1
- package/xpath/expressions/unary-minus-expr.d.ts +0 -8
- package/xpath/expressions/unary-minus-expr.js +0 -34
- package/xpath/expressions/unary-minus-expr.js.map +0 -1
- package/xpath/expressions/union-expr.d.ts +0 -9
- package/xpath/expressions/union-expr.js +0 -51
- package/xpath/expressions/union-expr.js.map +0 -1
- package/xpath/expressions/variable-expr.d.ts +0 -7
- package/xpath/expressions/variable-expr.js +0 -33
- package/xpath/expressions/variable-expr.js.map +0 -1
- package/xpath/functions/index.d.ts +0 -4
- package/xpath/functions/index.js +0 -21
- package/xpath/functions/index.js.map +0 -1
- package/xpath/functions/internal-functions.d.ts +0 -2
- package/xpath/functions/internal-functions.js +0 -22
- package/xpath/functions/internal-functions.js.map +0 -1
- package/xpath/functions/non-standard.d.ts +0 -12
- package/xpath/functions/non-standard.js +0 -45
- package/xpath/functions/non-standard.js.map +0 -1
- package/xpath/functions/standard-20.d.ts +0 -5
- package/xpath/functions/standard-20.js +0 -26
- package/xpath/functions/standard-20.js.map +0 -1
- package/xpath/functions/standard.d.ts +0 -40
- package/xpath/functions/standard.js +0 -442
- package/xpath/functions/standard.js.map +0 -1
- package/xpath/functions/xslt-specific.d.ts +0 -3
- package/xpath/functions/xslt-specific.js +0 -14
- package/xpath/functions/xslt-specific.js.map +0 -1
- package/xpath/grammar-rule-candidate.d.ts +0 -8
- package/xpath/grammar-rule-candidate.js +0 -3
- package/xpath/grammar-rule-candidate.js.map +0 -1
- package/xpath/index.d.ts +0 -3
- package/xpath/index.js +0 -20
- package/xpath/index.js.map +0 -1
- package/xpath/match-resolver.d.ts +0 -55
- package/xpath/match-resolver.js +0 -137
- package/xpath/match-resolver.js.map +0 -1
- package/xpath/node-tests/index.d.ts +0 -8
- package/xpath/node-tests/index.js +0 -18
- package/xpath/node-tests/index.js.map +0 -1
- package/xpath/node-tests/node-test-any.d.ts +0 -6
- package/xpath/node-tests/node-test-any.js +0 -15
- package/xpath/node-tests/node-test-any.js.map +0 -1
- package/xpath/node-tests/node-test-comment.d.ts +0 -6
- package/xpath/node-tests/node-test-comment.js +0 -15
- package/xpath/node-tests/node-test-comment.js.map +0 -1
- package/xpath/node-tests/node-test-element-or-attribute.d.ts +0 -6
- package/xpath/node-tests/node-test-element-or-attribute.js +0 -16
- package/xpath/node-tests/node-test-element-or-attribute.js.map +0 -1
- package/xpath/node-tests/node-test-name.d.ts +0 -10
- package/xpath/node-tests/node-test-name.js +0 -39
- package/xpath/node-tests/node-test-name.js.map +0 -1
- package/xpath/node-tests/node-test-nc.d.ts +0 -9
- package/xpath/node-tests/node-test-nc.js +0 -17
- package/xpath/node-tests/node-test-nc.js.map +0 -1
- package/xpath/node-tests/node-test-pi.d.ts +0 -8
- package/xpath/node-tests/node-test-pi.js +0 -17
- package/xpath/node-tests/node-test-pi.js.map +0 -1
- package/xpath/node-tests/node-test-text.d.ts +0 -6
- package/xpath/node-tests/node-test-text.js +0 -15
- package/xpath/node-tests/node-test-text.js.map +0 -1
- package/xpath/node-tests/node-test.d.ts +0 -5
- package/xpath/node-tests/node-test.js +0 -3
- package/xpath/node-tests/node-test.js.map +0 -1
- package/xpath/tokens.d.ts +0 -62
- package/xpath/tokens.js +0 -301
- package/xpath/tokens.js.map +0 -1
- package/xpath/values/boolean-value.d.ts +0 -11
- package/xpath/values/boolean-value.js +0 -24
- package/xpath/values/boolean-value.js.map +0 -1
- package/xpath/values/index.d.ts +0 -5
- package/xpath/values/index.js +0 -47
- package/xpath/values/index.js.map +0 -1
- package/xpath/values/node-set-value.d.ts +0 -11
- package/xpath/values/node-set-value.js +0 -28
- package/xpath/values/node-set-value.js.map +0 -1
- package/xpath/values/node-value.d.ts +0 -7
- package/xpath/values/node-value.js +0 -3
- package/xpath/values/node-value.js.map +0 -1
- package/xpath/values/number-value.d.ts +0 -11
- package/xpath/values/number-value.js +0 -24
- package/xpath/values/number-value.js.map +0 -1
- package/xpath/values/string-value.d.ts +0 -11
- package/xpath/values/string-value.js +0 -24
- package/xpath/values/string-value.js.map +0 -1
- package/xpath/xpath-grammar-rules.d.ts +0 -68
- package/xpath/xpath-grammar-rules.js +0 -75
- package/xpath/xpath-grammar-rules.js.map +0 -1
- package/xpath/xpath-token-rule.d.ts +0 -7
- package/xpath/xpath-token-rule.js +0 -3
- package/xpath/xpath-token-rule.js.map +0 -1
- package/xpath/xpath.d.ts +0 -174
- package/xpath/xpath.js +0 -912
- package/xpath/xpath.js.map +0 -1
- package/xpathdebug.d.ts +0 -2
- package/xpathdebug.js +0 -188
- package/xpathdebug.js.map +0 -1
- package/xslt/index.d.ts +0 -3
- package/xslt/index.js +0 -20
- package/xslt/index.js.map +0 -1
- package/xslt/xslt-decimal-format-settings.d.ts +0 -28
- package/xslt/xslt-decimal-format-settings.js +0 -3
- package/xslt/xslt-decimal-format-settings.js.map +0 -1
- package/xslt/xslt-options.d.ts +0 -7
- package/xslt/xslt-options.js +0 -3
- package/xslt/xslt-options.js.map +0 -1
- package/xslt/xslt-parameter.d.ts +0 -5
- package/xslt/xslt-parameter.js +0 -3
- package/xslt/xslt-parameter.js.map +0 -1
- package/xslt/xslt.d.ts +0 -275
- package/xslt/xslt.js +0 -1329
- package/xslt/xslt.js.map +0 -1
package/index.d.mts
ADDED
|
@@ -0,0 +1,817 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Our W3C DOM Node implementation. Note we call it XNode because we
|
|
3
|
+
* can't define the identifier Node. We do this mostly for Opera,
|
|
4
|
+
* where we can't reuse the HTML DOM for parsing our own XML, and for
|
|
5
|
+
* Safari, where it is too expensive to have the template processor.
|
|
6
|
+
*/
|
|
7
|
+
declare class XNode {
|
|
8
|
+
id: number;
|
|
9
|
+
childNodes: XNode[];
|
|
10
|
+
nodeType: number;
|
|
11
|
+
nodeName: string;
|
|
12
|
+
nodeValue: any;
|
|
13
|
+
firstChild: XNode;
|
|
14
|
+
lastChild: XNode;
|
|
15
|
+
nextSibling: XNode;
|
|
16
|
+
previousSibling: XNode;
|
|
17
|
+
siblingPosition: number;
|
|
18
|
+
ownerDocument: any;
|
|
19
|
+
namespaceUri: any;
|
|
20
|
+
prefix: string;
|
|
21
|
+
localName: string;
|
|
22
|
+
parentNode: XNode;
|
|
23
|
+
visited: boolean;
|
|
24
|
+
escape: boolean;
|
|
25
|
+
static _unusedXNodes: any[];
|
|
26
|
+
constructor(type: number, name: string, opt_value: any, opt_owner: any, opt_namespace?: any);
|
|
27
|
+
/**
|
|
28
|
+
* Node initialization. Called by the constructor and `recycle` method.
|
|
29
|
+
* @param type The node type.
|
|
30
|
+
* @param name The node name.
|
|
31
|
+
* @param value The node value.
|
|
32
|
+
* @param owner The node owner.
|
|
33
|
+
* @param namespaceUri The node namespace.
|
|
34
|
+
*/
|
|
35
|
+
init(type: number, name: string, value: string, owner: any, namespaceUri: any): void;
|
|
36
|
+
protected qualifiedNameToParts(name: string): string[];
|
|
37
|
+
protected domTraverseElements(node: XNode, opt_pre: Function, opt_post: any): boolean;
|
|
38
|
+
static recycle(node: any): void;
|
|
39
|
+
static create(type: any, name: string, value: any, owner: any, namespace?: any): XNode;
|
|
40
|
+
static clone(node: XNode, newOwner: XNode): XNode;
|
|
41
|
+
appendChild(node: XNode): void;
|
|
42
|
+
replaceChild(newNode: any, oldNode: any): void;
|
|
43
|
+
insertBefore(newNode: any, oldNode: any): void;
|
|
44
|
+
removeChild(node: XNode): void;
|
|
45
|
+
hasAttributes(): boolean;
|
|
46
|
+
setAttribute(name: string, value: any): void;
|
|
47
|
+
setAttributeNS(namespace: any, name: any, value: any): void;
|
|
48
|
+
getAttributeValue(name: string): any;
|
|
49
|
+
getAttributeNS(namespace: any, localName: any): any;
|
|
50
|
+
hasAttribute(name: string): boolean;
|
|
51
|
+
hasAttributeNS(namespace: string, localName: string): boolean;
|
|
52
|
+
removeAttribute(name: string): void;
|
|
53
|
+
removeAttributeNS(namespace: string, localName: string): void;
|
|
54
|
+
getElementsByTagName(name: string): any[];
|
|
55
|
+
getElementsByTagNameNS(namespace: string, localName: string): any[];
|
|
56
|
+
getElementById(id: any): any;
|
|
57
|
+
getAncestorByLocalName(localName: string): XNode | undefined;
|
|
58
|
+
getAncestorById(id: number): XNode | undefined;
|
|
59
|
+
toString(): string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare class XDocument extends XNode {
|
|
63
|
+
documentElement: any;
|
|
64
|
+
constructor();
|
|
65
|
+
appendChild(node: any): void;
|
|
66
|
+
createElement(name: string): XNode;
|
|
67
|
+
createElementNS(namespace: any, name: any): XNode;
|
|
68
|
+
createDocumentFragment(): XNode;
|
|
69
|
+
createTextNode(value: any): XNode;
|
|
70
|
+
createAttribute(name: any): XNode;
|
|
71
|
+
createAttributeNS(namespace: any, name: any): XNode;
|
|
72
|
+
createComment(data: any): XNode;
|
|
73
|
+
createCDATASection(data: any): XNode;
|
|
74
|
+
createDTDSection(data: any): XNode;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Escape XML special markup characters: tag delimiter <, >, and entity
|
|
79
|
+
* reference start delimiter &. The escaped string can be used in XML
|
|
80
|
+
* text portions (i.e. between tags).
|
|
81
|
+
* @param s The string to be escaped.
|
|
82
|
+
* @returns The escaped string.
|
|
83
|
+
*/
|
|
84
|
+
declare function xmlEscapeText(s: string): string;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Original author: Steffen Meschkat <mesch@google.com> (the `xmlParse` function,
|
|
88
|
+
* now `xmlStrictParse`).
|
|
89
|
+
*
|
|
90
|
+
* An XML parse and a minimal DOM implementation that just supports
|
|
91
|
+
* the subset of the W3C DOM that is used in the XSLT implementation.
|
|
92
|
+
*/
|
|
93
|
+
declare class XmlParser {
|
|
94
|
+
regexEmpty: RegExp;
|
|
95
|
+
XML10_TAGNAME_REGEXP: RegExp;
|
|
96
|
+
XML10_ATTRIBUTE_REGEXP: RegExp;
|
|
97
|
+
XML11_TAGNAME_REGEXP: RegExp;
|
|
98
|
+
XML11_ATTRIBUTE_REGEXP: RegExp;
|
|
99
|
+
lenientHtmlTags: string[];
|
|
100
|
+
/**
|
|
101
|
+
* The entry point for this parser.
|
|
102
|
+
* It verifies whether the document seems to be HTML.
|
|
103
|
+
* HTML is a special case if XML and it should be parsed differently.
|
|
104
|
+
* @param xmlOrHtml The XML or HTML content to be parsed.
|
|
105
|
+
* @returns A DOM document.
|
|
106
|
+
*/
|
|
107
|
+
xmlParse(xmlOrHtml: string): XDocument;
|
|
108
|
+
/**
|
|
109
|
+
* Given an XNode, returns an object mapping prefixes to their corresponding namespaces in its scope.
|
|
110
|
+
* Default namespace is treated as if its prefix were the empty string.
|
|
111
|
+
* @param node The Node.
|
|
112
|
+
* @returns An object with prefixes and namespace URLs.
|
|
113
|
+
*/
|
|
114
|
+
private namespaceMapAt;
|
|
115
|
+
/**
|
|
116
|
+
* HTML needs to be parsed differently because it's a special case of XML.
|
|
117
|
+
* Sources:
|
|
118
|
+
*
|
|
119
|
+
* - https://blog.teamtreehouse.com/to-close-or-not-to-close-tags-in-html5
|
|
120
|
+
* @param htmlText The HTML text
|
|
121
|
+
* @returns A DOM document.
|
|
122
|
+
*/
|
|
123
|
+
private htmlParse;
|
|
124
|
+
/**
|
|
125
|
+
* Parses the given XML string with our custom, JavaScript XML parser.
|
|
126
|
+
* @param xml The XML String.
|
|
127
|
+
* @returns A XDocument.
|
|
128
|
+
* @author Steffen Meschkat <mesch@google.com>
|
|
129
|
+
*/
|
|
130
|
+
private xmlStrictParse;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Represents a DOM-like node interface for XPath evaluation.
|
|
135
|
+
* This is compatible with browser DOM nodes and can be extended for other implementations.
|
|
136
|
+
*/
|
|
137
|
+
interface XPathNode {
|
|
138
|
+
nodeType: number;
|
|
139
|
+
nodeName: string;
|
|
140
|
+
localName?: string;
|
|
141
|
+
namespaceURI?: string | null;
|
|
142
|
+
textContent?: string | null;
|
|
143
|
+
parentNode?: XPathNode | null;
|
|
144
|
+
childNodes?: ArrayLike<XPathNode>;
|
|
145
|
+
attributes?: ArrayLike<XPathNode>;
|
|
146
|
+
nextSibling?: XPathNode | null;
|
|
147
|
+
previousSibling?: XPathNode | null;
|
|
148
|
+
ownerDocument?: XPathNode | null;
|
|
149
|
+
documentElement?: XPathNode;
|
|
150
|
+
target?: string;
|
|
151
|
+
getAttribute?(name: string): string | null;
|
|
152
|
+
compareDocumentPosition?(other: XPathNode): number;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Type for custom XPath functions that can be registered in the context.
|
|
157
|
+
*/
|
|
158
|
+
type XPathFunction = (...args: any[]) => any;
|
|
159
|
+
/**
|
|
160
|
+
* Type for the variables map in the context.
|
|
161
|
+
*/
|
|
162
|
+
type XPathVariables = Record<string, any>;
|
|
163
|
+
/**
|
|
164
|
+
* Type for the custom functions map in the context.
|
|
165
|
+
*/
|
|
166
|
+
type XPathFunctions = Record<string, XPathFunction>;
|
|
167
|
+
/**
|
|
168
|
+
* Type for namespace bindings (prefix -> namespace URI).
|
|
169
|
+
*/
|
|
170
|
+
type XPathNamespaces = Record<string, string>;
|
|
171
|
+
/**
|
|
172
|
+
* The evaluation context for XPath expressions.
|
|
173
|
+
*
|
|
174
|
+
* This context is passed to all expression evaluate() methods and contains:
|
|
175
|
+
* - The current context node
|
|
176
|
+
* - Position information for predicates
|
|
177
|
+
* - Variable bindings
|
|
178
|
+
* - Custom function definitions
|
|
179
|
+
*/
|
|
180
|
+
interface XPathContext {
|
|
181
|
+
/**
|
|
182
|
+
* The current context node being evaluated.
|
|
183
|
+
*/
|
|
184
|
+
node?: XPathNode;
|
|
185
|
+
/**
|
|
186
|
+
* The position of the context node within the current node set (1-based).
|
|
187
|
+
* Used by position() function and numeric predicates.
|
|
188
|
+
*/
|
|
189
|
+
position?: number;
|
|
190
|
+
/**
|
|
191
|
+
* The size of the current node set.
|
|
192
|
+
* Used by last() function.
|
|
193
|
+
*/
|
|
194
|
+
size?: number;
|
|
195
|
+
/**
|
|
196
|
+
* The full node list for the current context.
|
|
197
|
+
* Used by the 'self-and-siblings' axis (XSLT-specific).
|
|
198
|
+
*/
|
|
199
|
+
nodeList?: XPathNode[];
|
|
200
|
+
/**
|
|
201
|
+
* Variable bindings available during evaluation.
|
|
202
|
+
* Variables are referenced in XPath as $variableName.
|
|
203
|
+
*/
|
|
204
|
+
variables?: XPathVariables;
|
|
205
|
+
/**
|
|
206
|
+
* Custom functions available during evaluation.
|
|
207
|
+
* These extend the built-in XPath 1.0 function library.
|
|
208
|
+
*/
|
|
209
|
+
functions?: XPathFunctions;
|
|
210
|
+
/**
|
|
211
|
+
* Namespace bindings for resolving prefixes in XPath expressions.
|
|
212
|
+
* Maps namespace prefixes to namespace URIs.
|
|
213
|
+
* Example: { "atom": "http://www.w3.org/2005/Atom" }
|
|
214
|
+
*/
|
|
215
|
+
namespaces?: XPathNamespaces;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Result types that can be returned from XPath evaluation.
|
|
219
|
+
*/
|
|
220
|
+
type XPathResult = XPathNode[] | string | number | boolean;
|
|
221
|
+
|
|
222
|
+
declare abstract class XPathExpression {
|
|
223
|
+
abstract evaluate(context: XPathContext): XPathResult;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* According to https://www.w3schools.com/xml/ref_xsl_el_decimal-format.asp:
|
|
228
|
+
*
|
|
229
|
+
* @property {string} name: Optional. Specifies a name for this format.
|
|
230
|
+
* @property {string} decimalSeparator: Optional. Specifies the decimal point character. Default is ".".
|
|
231
|
+
* @property {string} groupingSeparator: Optional. Specifies the thousands separator character. Default is ",".
|
|
232
|
+
* @property {string} infinity: Optional. Specifies the string used to represent infinity. Default is "Infinity".
|
|
233
|
+
* @property {string} minusSign: Optional. Specifies the character to represent negative numbers. Default is "-".
|
|
234
|
+
* @property {string} naN: Optional. Specifies the string used when the value is not a number". Default is "NaN".
|
|
235
|
+
* @property {string} percent: Optional. Specifies the percentage sign character. Default is "%".
|
|
236
|
+
* @property {string} perMille: Optional. Specifies the per thousand sign character. Default is "‰".
|
|
237
|
+
* @property {string} zeroDigit: Optional. Specifies the digit zero character. Default is "0".
|
|
238
|
+
* @property {string} digit: Optional. Specifies the character used to indicate a place where a digit is required. Default is #.
|
|
239
|
+
* @property {string} patternSeparator: Optional. Specifies the character used to separate positive and negative subpatterns in a format pattern. Default is ";".
|
|
240
|
+
*/
|
|
241
|
+
type XsltDecimalFormatSettings = {
|
|
242
|
+
name?: string;
|
|
243
|
+
decimalSeparator: string;
|
|
244
|
+
groupingSeparator: string;
|
|
245
|
+
infinity: string;
|
|
246
|
+
minusSign: string;
|
|
247
|
+
naN: string;
|
|
248
|
+
percent: string;
|
|
249
|
+
perMille: string;
|
|
250
|
+
zeroDigit: string;
|
|
251
|
+
digit: string;
|
|
252
|
+
patternSeparator: string;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
interface NodeValue {
|
|
256
|
+
stringValue(): string;
|
|
257
|
+
booleanValue(): boolean;
|
|
258
|
+
numberValue(): number;
|
|
259
|
+
nodeSetValue(): XNode[];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* XPath expression evaluation context. An XPath context consists of a
|
|
264
|
+
* DOM node, a list of DOM nodes that contains this node, a number
|
|
265
|
+
* that represents the position of the single node in the list, and a
|
|
266
|
+
* current set of variable bindings. (See XPath spec.)
|
|
267
|
+
*
|
|
268
|
+
* setVariable(name, expr) -- binds given XPath expression to the
|
|
269
|
+
* name.
|
|
270
|
+
*
|
|
271
|
+
* getVariable(name) -- what the name says.
|
|
272
|
+
*
|
|
273
|
+
* setNode(position) -- sets the context to the node at the given
|
|
274
|
+
* position. Needed to implement scoping rules for variables in
|
|
275
|
+
* XPath. (A variable is visible to all subsequent siblings, not
|
|
276
|
+
* only to its children.)
|
|
277
|
+
*
|
|
278
|
+
* set/isCaseInsensitive -- specifies whether node name tests should
|
|
279
|
+
* be case sensitive. If you're executing xpaths against a regular
|
|
280
|
+
* HTML DOM, you probably don't want case-sensitivity, because
|
|
281
|
+
* browsers tend to disagree about whether elements & attributes
|
|
282
|
+
* should be upper/lower case. If you're running xpaths in an
|
|
283
|
+
* XSLT instance, you probably DO want case sensitivity, as per the
|
|
284
|
+
* XSL spec.
|
|
285
|
+
*
|
|
286
|
+
* set/isReturnOnFirstMatch -- whether XPath evaluation should quit as soon
|
|
287
|
+
* as a result is found. This is an optimization that might make sense if you
|
|
288
|
+
* only care about the first result.
|
|
289
|
+
*
|
|
290
|
+
* set/isIgnoreNonElementNodesForNTA -- whether to ignore non-element nodes
|
|
291
|
+
* when evaluating the "node()" any node test. While technically this is
|
|
292
|
+
* contrary to the XPath spec, practically it can enhance performance
|
|
293
|
+
* significantly, and makes sense if you a) use "node()" when you mean "*",
|
|
294
|
+
* and b) use "//" when you mean "/descendant::* /".
|
|
295
|
+
*/
|
|
296
|
+
declare class ExprContext {
|
|
297
|
+
position: number;
|
|
298
|
+
nodeList: XNode[];
|
|
299
|
+
xsltVersion: '1.0' | '2.0' | '3.0';
|
|
300
|
+
variables: {
|
|
301
|
+
[name: string]: NodeValue;
|
|
302
|
+
};
|
|
303
|
+
keys: {
|
|
304
|
+
[name: string]: {
|
|
305
|
+
[key: string]: NodeValue;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
knownNamespaces: {
|
|
309
|
+
[alias: string]: string;
|
|
310
|
+
};
|
|
311
|
+
caseInsensitive: any;
|
|
312
|
+
ignoreAttributesWithoutValue: any;
|
|
313
|
+
returnOnFirstMatch: any;
|
|
314
|
+
ignoreNonElementNodesForNTA: any;
|
|
315
|
+
parent: ExprContext;
|
|
316
|
+
root: XNode;
|
|
317
|
+
decimalFormatSettings: XsltDecimalFormatSettings;
|
|
318
|
+
inApplyTemplates: boolean;
|
|
319
|
+
baseTemplateMatched: boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Constructor -- gets the node, its position, the node set it
|
|
322
|
+
* belongs to, and a parent context as arguments. The parent context
|
|
323
|
+
* is used to implement scoping rules for variables: if a variable
|
|
324
|
+
* is not found in the current context, it is looked for in the
|
|
325
|
+
* parent context, recursively. Except for node, all arguments have
|
|
326
|
+
* default values: default position is 0, default node set is the
|
|
327
|
+
* set that contains only the node, and the default parent is null.
|
|
328
|
+
*
|
|
329
|
+
* Notice that position starts at 0 at the outside interface;
|
|
330
|
+
* inside XPath expressions this shows up as position()=1.
|
|
331
|
+
* @param nodeList TODO
|
|
332
|
+
* @param opt_position TODO
|
|
333
|
+
* @param opt_parent TODO
|
|
334
|
+
* @param opt_caseInsensitive TODO
|
|
335
|
+
* @param opt_ignoreAttributesWithoutValue TODO
|
|
336
|
+
* @param opt_returnOnFirstMatch TODO
|
|
337
|
+
* @param opt_ignoreNonElementNodesForNTA TODO
|
|
338
|
+
*/
|
|
339
|
+
constructor(nodeList: XNode[], xsltVersion?: '1.0' | '2.0' | '3.0', opt_position?: number, opt_decimalFormatSettings?: XsltDecimalFormatSettings, opt_variables?: {
|
|
340
|
+
[name: string]: any;
|
|
341
|
+
}, opt_knownNamespaces?: {
|
|
342
|
+
[alias: string]: string;
|
|
343
|
+
}, opt_parent?: ExprContext, opt_caseInsensitive?: any, opt_ignoreAttributesWithoutValue?: any, opt_returnOnFirstMatch?: any, opt_ignoreNonElementNodesForNTA?: any);
|
|
344
|
+
/**
|
|
345
|
+
* clone() -- creates a new context with the current context as
|
|
346
|
+
* parent. If passed as argument to clone(), the new context has a
|
|
347
|
+
* different node, position, or node set. What is not passed is
|
|
348
|
+
* inherited from the cloned context.
|
|
349
|
+
* @param opt_nodeList TODO
|
|
350
|
+
* @param opt_position TODO
|
|
351
|
+
* @returns TODO
|
|
352
|
+
*/
|
|
353
|
+
clone(opt_nodeList?: XNode[], opt_position?: number): ExprContext;
|
|
354
|
+
setVariable(name?: string, value?: NodeValue | string): void;
|
|
355
|
+
getVariable(name: string): NodeValue;
|
|
356
|
+
setNode(position: number): void;
|
|
357
|
+
contextSize(): number;
|
|
358
|
+
isCaseInsensitive(): any;
|
|
359
|
+
setCaseInsensitive(caseInsensitive: any): any;
|
|
360
|
+
isIgnoreAttributesWithoutValue(): any;
|
|
361
|
+
setIgnoreAttributesWithoutValue(ignore: any): any;
|
|
362
|
+
isReturnOnFirstMatch(): any;
|
|
363
|
+
setReturnOnFirstMatch(returnOnFirstMatch: any): any;
|
|
364
|
+
isIgnoreNonElementNodesForNTA(): any;
|
|
365
|
+
setIgnoreNonElementNodesForNTA(ignoreNonElementNodesForNTA: any): any;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Expression wrapper that provides backward-compatible interface.
|
|
370
|
+
* Wraps new XPath expressions to work with old ExprContext.
|
|
371
|
+
*/
|
|
372
|
+
declare class Expression {
|
|
373
|
+
protected xpathExpression: XPathExpression;
|
|
374
|
+
protected nodeConverter: NodeConverter;
|
|
375
|
+
absolute?: boolean;
|
|
376
|
+
steps?: any[];
|
|
377
|
+
constructor(xpathExpression: XPathExpression, nodeConverter: NodeConverter);
|
|
378
|
+
/**
|
|
379
|
+
* Evaluate the expression in the given context.
|
|
380
|
+
*/
|
|
381
|
+
evaluate(context: ExprContext): NodeValue;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Handles conversion between ExprContext and XPathContext.
|
|
385
|
+
* Uses XNode directly as XPathNode-compatible objects to preserve node identity.
|
|
386
|
+
*/
|
|
387
|
+
declare class NodeConverter {
|
|
388
|
+
/**
|
|
389
|
+
* Convert ExprContext to XPathContext for the new XPath implementation.
|
|
390
|
+
* XNodes are used directly since they implement enough of the XPathNode interface.
|
|
391
|
+
*/
|
|
392
|
+
exprContextToXPathContext(exprContext: ExprContext): XPathContext;
|
|
393
|
+
/**
|
|
394
|
+
* Adapt XNode to be compatible with XPathNode interface.
|
|
395
|
+
* We add missing properties but keep the original XNode reference.
|
|
396
|
+
*/
|
|
397
|
+
adaptXNode(node: XNode): XPathNode;
|
|
398
|
+
/**
|
|
399
|
+
* Convert XPathNode result back to XNode.
|
|
400
|
+
* Since we're now using XNodes directly, this is mostly a type cast.
|
|
401
|
+
*/
|
|
402
|
+
xPathNodeToXNode(xpathNode: XPathNode): XNode | null;
|
|
403
|
+
/**
|
|
404
|
+
* Get text content from an XNode.
|
|
405
|
+
*/
|
|
406
|
+
private getTextContent;
|
|
407
|
+
/**
|
|
408
|
+
* Convert variables from ExprContext format to XPathContext format.
|
|
409
|
+
*/
|
|
410
|
+
private convertVariables;
|
|
411
|
+
/**
|
|
412
|
+
* Create custom functions for XPath context (like key(), document(), etc.).
|
|
413
|
+
*/
|
|
414
|
+
private createCustomFunctions;
|
|
415
|
+
/**
|
|
416
|
+
* Convert an XML node to a JSON string representation.
|
|
417
|
+
* This is a simplified implementation of XSLT 3.0's xml-to-json().
|
|
418
|
+
*/
|
|
419
|
+
private xmlToJson;
|
|
420
|
+
/**
|
|
421
|
+
* Wrap XPath result in appropriate NodeValue type.
|
|
422
|
+
*/
|
|
423
|
+
wrapResult(result: XPathResult, exprContext: ExprContext): NodeValue;
|
|
424
|
+
/**
|
|
425
|
+
* Clear any internal state if needed.
|
|
426
|
+
*/
|
|
427
|
+
clearCache(): void;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* XPath class that uses the new lexer/parser implementation
|
|
431
|
+
* while maintaining API compatibility with the old implementation.
|
|
432
|
+
*/
|
|
433
|
+
declare class XPath {
|
|
434
|
+
private lexer;
|
|
435
|
+
private parser;
|
|
436
|
+
private nodeConverter;
|
|
437
|
+
private parseCache;
|
|
438
|
+
constructor();
|
|
439
|
+
/**
|
|
440
|
+
* Parse an XPath expression and return an Expression object.
|
|
441
|
+
* @param expression The XPath expression string.
|
|
442
|
+
* @param axis Optional axis override for relative paths.
|
|
443
|
+
*/
|
|
444
|
+
xPathParse(expression: string, axis?: string): Expression;
|
|
445
|
+
/**
|
|
446
|
+
* Parse and evaluate an XPath expression.
|
|
447
|
+
* @param select The XPath expression string.
|
|
448
|
+
* @param context The expression context.
|
|
449
|
+
*/
|
|
450
|
+
xPathEval(select: string, context: ExprContext): NodeValue;
|
|
451
|
+
/**
|
|
452
|
+
* Sort nodes in context according to sort specifications.
|
|
453
|
+
* @param context The expression context with nodes to sort.
|
|
454
|
+
* @param sort Array of sort specifications.
|
|
455
|
+
*/
|
|
456
|
+
xPathSort(context: ExprContext, sort: any[]): void;
|
|
457
|
+
/**
|
|
458
|
+
* Comparison function for sorting.
|
|
459
|
+
*/
|
|
460
|
+
private xPathSortByKey;
|
|
461
|
+
/**
|
|
462
|
+
* Wrap a new XPath expression in the backward-compatible Expression class.
|
|
463
|
+
*/
|
|
464
|
+
private wrapExpression;
|
|
465
|
+
/**
|
|
466
|
+
* Clear parse cache (useful for testing or memory management).
|
|
467
|
+
*/
|
|
468
|
+
clearCache(): void;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Class that resolves XPath expressions, returning nodes.
|
|
473
|
+
* This is used for XSLT pattern matching.
|
|
474
|
+
*/
|
|
475
|
+
declare class MatchResolver {
|
|
476
|
+
/**
|
|
477
|
+
* Entry point for expression matching.
|
|
478
|
+
* @param expression The expression to be resolved.
|
|
479
|
+
* @param context The Expression Context.
|
|
480
|
+
* @returns An array of nodes.
|
|
481
|
+
*/
|
|
482
|
+
expressionMatch(expression: Expression, context: ExprContext): XNode[];
|
|
483
|
+
/**
|
|
484
|
+
* Resolves a LocationExpr.
|
|
485
|
+
* @param expression The Location Expression.
|
|
486
|
+
* @param context The Expression Context.
|
|
487
|
+
* @returns Either the results of a relative resolution, or the results of an
|
|
488
|
+
* absolute resolution.
|
|
489
|
+
*/
|
|
490
|
+
private locationExpressionMatch;
|
|
491
|
+
/**
|
|
492
|
+
* Resolves a UnionExpr.
|
|
493
|
+
* @param expression The Union Expression.
|
|
494
|
+
* @param context The Expression Context.
|
|
495
|
+
* @returns The concatenated result of evaluating both sides of the expression.
|
|
496
|
+
*/
|
|
497
|
+
private unionExpressionMatch;
|
|
498
|
+
/**
|
|
499
|
+
* Finds all the nodes through absolute XPath search, starting on
|
|
500
|
+
* the #document parent node.
|
|
501
|
+
* @param expression The Expression.
|
|
502
|
+
* @param context The Expression Context.
|
|
503
|
+
* @returns The list of found nodes.
|
|
504
|
+
*/
|
|
505
|
+
private absoluteXsltMatchByDocumentNode;
|
|
506
|
+
/**
|
|
507
|
+
* Finds all the nodes through absolute XPath search, starting with the
|
|
508
|
+
* first child of the #document node.
|
|
509
|
+
* @param expression The Expression.
|
|
510
|
+
* @param context The Expression Context.
|
|
511
|
+
* @returns The list of found nodes.
|
|
512
|
+
*/
|
|
513
|
+
private absoluteXsltMatch;
|
|
514
|
+
/**
|
|
515
|
+
* Tries to find relative nodes from the actual context position.
|
|
516
|
+
* If found nodes are already in the context, or if they are children of
|
|
517
|
+
* nodes in the context, they are returned.
|
|
518
|
+
* @param expression The expression used.
|
|
519
|
+
* @param context The Expression Context.
|
|
520
|
+
* @returns The list of found nodes.
|
|
521
|
+
*/
|
|
522
|
+
private relativeXsltMatch;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
type XsltParameter = {
|
|
526
|
+
name: string;
|
|
527
|
+
namespaceUri?: string;
|
|
528
|
+
value: any;
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
type XsltOptions = {
|
|
532
|
+
cData: boolean;
|
|
533
|
+
escape: boolean;
|
|
534
|
+
selfClosingTags: boolean;
|
|
535
|
+
parameters?: XsltParameter[];
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* The main class for XSL-T processing. The implementation is NOT
|
|
540
|
+
* complete; some xsl element are left out.
|
|
541
|
+
*
|
|
542
|
+
* References:
|
|
543
|
+
*
|
|
544
|
+
* [XSLT] XSL-T Specification
|
|
545
|
+
* <http://www.w3.org/TR/1999/REC-xslt-19991116>.
|
|
546
|
+
*
|
|
547
|
+
* [ECMA] ECMAScript Language Specification
|
|
548
|
+
* <http://www.ecma-international.org/publications/standards/Ecma-262.htm>.
|
|
549
|
+
*
|
|
550
|
+
* The XSL processor API has one entry point, the function
|
|
551
|
+
* `xsltProcess()`. It receives as arguments the starting point in the
|
|
552
|
+
* input document as an XPath expression context, the DOM root node of
|
|
553
|
+
* the XSL-T stylesheet, and a DOM node that receives the output.
|
|
554
|
+
*
|
|
555
|
+
* NOTE: Actually, XSL-T processing according to the specification is
|
|
556
|
+
* defined as operation on text documents, not as operation on DOM
|
|
557
|
+
* trees. So, strictly speaking, this implementation is not an XSL-T
|
|
558
|
+
* processor, but the processing engine that needs to be complemented
|
|
559
|
+
* by an XML parser and serializer in order to be complete. Those two
|
|
560
|
+
* are found in the `dom` folder.
|
|
561
|
+
*/
|
|
562
|
+
declare class Xslt {
|
|
563
|
+
xPath: XPath;
|
|
564
|
+
xmlParser: XmlParser;
|
|
565
|
+
matchResolver: MatchResolver;
|
|
566
|
+
options: XsltOptions;
|
|
567
|
+
decimalFormatSettings: XsltDecimalFormatSettings;
|
|
568
|
+
outputDocument: XDocument;
|
|
569
|
+
outputMethod: 'xml' | 'html' | 'text' | 'name' | 'xhtml';
|
|
570
|
+
outputOmitXmlDeclaration: string;
|
|
571
|
+
version: string;
|
|
572
|
+
firstTemplateRan: boolean;
|
|
573
|
+
constructor(options?: Partial<XsltOptions>);
|
|
574
|
+
/**
|
|
575
|
+
* The exported entry point of the XSL-T processor.
|
|
576
|
+
* @param xmlDoc The input document root, as DOM node.
|
|
577
|
+
* @param stylesheet The stylesheet document root, as DOM node.
|
|
578
|
+
* @returns the processed document, as XML text in a string.
|
|
579
|
+
*/
|
|
580
|
+
xsltProcess(xmlDoc: XDocument, stylesheet: XDocument): Promise<string>;
|
|
581
|
+
/**
|
|
582
|
+
* The main entry point of the XSL-T processor, as explained on the top of the file.
|
|
583
|
+
* @param context The input document root, as XPath `ExprContext`.
|
|
584
|
+
* @param template The stylesheet document root, as DOM node.
|
|
585
|
+
* @param output If set, the output where the transformation should occur.
|
|
586
|
+
*/
|
|
587
|
+
protected xsltProcessContext(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
588
|
+
/**
|
|
589
|
+
* Implements `xsl:apply-templates`.
|
|
590
|
+
* @param context The Expression Context.
|
|
591
|
+
* @param template The template.
|
|
592
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
593
|
+
* @protected
|
|
594
|
+
*/
|
|
595
|
+
protected xsltApplyTemplates(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
596
|
+
/**
|
|
597
|
+
* Implements `xsl:attribute`.
|
|
598
|
+
* @param context The Expression Context.
|
|
599
|
+
* @param template The template.
|
|
600
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
601
|
+
* @protected
|
|
602
|
+
*/
|
|
603
|
+
protected xsltAttribute(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
604
|
+
/**
|
|
605
|
+
* Implements `xsl:call-template`.
|
|
606
|
+
* @param context The Expression Context.
|
|
607
|
+
* @param template The template.
|
|
608
|
+
* @param output The output, used when a fragment is passed by a previous step.
|
|
609
|
+
*/
|
|
610
|
+
protected xsltCallTemplate(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
611
|
+
/**
|
|
612
|
+
* Implements `xsl:choose`, its child nodes `xsl:when`, and
|
|
613
|
+
* `xsl:otherwise`.
|
|
614
|
+
* @param context The Expression Context.
|
|
615
|
+
* @param template The template.
|
|
616
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
617
|
+
*/
|
|
618
|
+
protected xsltChoose(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
619
|
+
/**
|
|
620
|
+
* Implements `xsl:copy` for all node types.
|
|
621
|
+
* @param {XNode} destination the node being copied to, part of output document.
|
|
622
|
+
* @param {XNode} source the node being copied, part in input document.
|
|
623
|
+
* @returns {XNode|null} If an element node was created, the element node. Otherwise, null.
|
|
624
|
+
*/
|
|
625
|
+
protected xsltCopy(destination: XNode, source: XNode): XNode;
|
|
626
|
+
/**
|
|
627
|
+
* Implements `xsl:comment`.
|
|
628
|
+
* @param context The Expression Context.
|
|
629
|
+
* @param template The template.
|
|
630
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
631
|
+
*/
|
|
632
|
+
protected xsltComment(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
633
|
+
/**
|
|
634
|
+
* Implements `xsl:copy-of` for node-set values of the select
|
|
635
|
+
* expression. Recurses down the source node tree, which is part of
|
|
636
|
+
* the input document.
|
|
637
|
+
* @param {XNode} destination the node being copied to, part of output document.
|
|
638
|
+
* @param {XNode} source the node being copied, part in input document.
|
|
639
|
+
*/
|
|
640
|
+
protected xsltCopyOf(destination: XNode, source: XNode): void;
|
|
641
|
+
/**
|
|
642
|
+
* Implements `xsl:decimal-format`, registering the settings in this instance
|
|
643
|
+
* and the current context.
|
|
644
|
+
* @param context The Expression Context.
|
|
645
|
+
* @param template The template.
|
|
646
|
+
*/
|
|
647
|
+
protected xsltDecimalFormat(context: ExprContext, template: XNode): void;
|
|
648
|
+
/**
|
|
649
|
+
* Implements `xsl:element`.
|
|
650
|
+
* @param context The Expression Context.
|
|
651
|
+
* @param template The template.
|
|
652
|
+
*/
|
|
653
|
+
protected xsltElement(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
654
|
+
/**
|
|
655
|
+
* Implements `xsl:for-each`.
|
|
656
|
+
* @param context The Expression Context.
|
|
657
|
+
* @param template The template.
|
|
658
|
+
* @param output The output.
|
|
659
|
+
*/
|
|
660
|
+
protected xsltForEach(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
661
|
+
/**
|
|
662
|
+
* Implements `xsl:if`.
|
|
663
|
+
* @param context The Expression Context.
|
|
664
|
+
* @param template The template.
|
|
665
|
+
* @param output The output.
|
|
666
|
+
*/
|
|
667
|
+
protected xsltIf(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
668
|
+
/**
|
|
669
|
+
* Common implementation for `<xsl:import>` and `<xsl:include>`.
|
|
670
|
+
* @param context The Expression Context.
|
|
671
|
+
* @param template The template.
|
|
672
|
+
* @param output The output.
|
|
673
|
+
* @param isImport Whether this is an import (true) or include (false).
|
|
674
|
+
*/
|
|
675
|
+
protected xsltImportOrInclude(context: ExprContext, template: XNode, output: XNode | undefined, isImport: boolean): Promise<void>;
|
|
676
|
+
/**
|
|
677
|
+
* Implements `<xsl:import>`. For now the code is nearly identical to `<xsl:include>`, but there's
|
|
678
|
+
* no precedence evaluation implemented yet.
|
|
679
|
+
* @param context The Expression Context.
|
|
680
|
+
* @param template The template.
|
|
681
|
+
* @param output The output.
|
|
682
|
+
*/
|
|
683
|
+
protected xsltImport(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
684
|
+
/**
|
|
685
|
+
* Implements `xsl:include`.
|
|
686
|
+
* @param context The Expression Context.
|
|
687
|
+
* @param template The template.
|
|
688
|
+
* @param output The output.
|
|
689
|
+
*/
|
|
690
|
+
protected xsltInclude(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
691
|
+
/**
|
|
692
|
+
* Implements `xsl:key`.
|
|
693
|
+
* @param context The Expression Context.
|
|
694
|
+
* @param template The template.
|
|
695
|
+
*/
|
|
696
|
+
protected xsltKey(context: ExprContext, template: XNode): void;
|
|
697
|
+
/**
|
|
698
|
+
* Orders the current node list in the input context according to the
|
|
699
|
+
* sort order specified by xsl:sort child nodes of the current
|
|
700
|
+
* template node. This happens before the operation specified by the
|
|
701
|
+
* current template node is executed.
|
|
702
|
+
* @param context The expression context.
|
|
703
|
+
* @param template The template node.
|
|
704
|
+
* @todo case-order is not implemented.
|
|
705
|
+
*/
|
|
706
|
+
protected xsltSort(context: ExprContext, template: XNode): void;
|
|
707
|
+
/**
|
|
708
|
+
* Implements `xsl:template`.
|
|
709
|
+
* @param context The Expression Context.
|
|
710
|
+
* @param template The `<xsl:template>` node.
|
|
711
|
+
* @param output The output. In general, a fragment that will be used by
|
|
712
|
+
* the caller.
|
|
713
|
+
*/
|
|
714
|
+
protected xsltTemplate(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
715
|
+
protected xsltText(context: ExprContext, template: XNode, output?: XNode): void;
|
|
716
|
+
/**
|
|
717
|
+
* Implements `<xsl:stylesheet>` and `<xsl:transform>`, and its corresponding
|
|
718
|
+
* validations.
|
|
719
|
+
* @param context The Expression Context.
|
|
720
|
+
* @param template The `<xsl:stylesheet>` or `<xsl:transform>` node.
|
|
721
|
+
* @param output The output. In general, a fragment that will be used by
|
|
722
|
+
* the caller.
|
|
723
|
+
*/
|
|
724
|
+
protected xsltTransformOrStylesheet(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
725
|
+
protected xsltValueOf(context: ExprContext, template: XNode, output?: XNode): void;
|
|
726
|
+
/**
|
|
727
|
+
* Evaluates a variable or parameter and set it in the current input
|
|
728
|
+
* context. Implements `xsl:variable`, `xsl:param`, and `xsl:with-param`.
|
|
729
|
+
*
|
|
730
|
+
* @param context The expression context.
|
|
731
|
+
* @param template The template node.
|
|
732
|
+
* @param override flag that defines if the value computed here
|
|
733
|
+
* overrides the one already in the input context if that is the
|
|
734
|
+
* case. I.e. decides if this is a default value or a local
|
|
735
|
+
* value. `xsl:variable` and `xsl:with-param` override; `xsl:param` doesn't.
|
|
736
|
+
*/
|
|
737
|
+
protected xsltVariable(context: ExprContext, template: XNode, override: boolean): Promise<void>;
|
|
738
|
+
/**
|
|
739
|
+
* Traverses the template node tree. Calls the main processing
|
|
740
|
+
* function with the current input context for every child node of the
|
|
741
|
+
* current template node.
|
|
742
|
+
* @param context Normally the Expression Context.
|
|
743
|
+
* @param template The XSL-T definition.
|
|
744
|
+
* @param output If set, the output where the transformation should occur.
|
|
745
|
+
*/
|
|
746
|
+
protected xsltChildNodes(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
747
|
+
/**
|
|
748
|
+
* This logic is used in two different places:
|
|
749
|
+
* - `xsltPassThrough`, if the template asks this library to write a text node;
|
|
750
|
+
* - `xsltProcessContext`, `apply-templates` operation, when the current node is text.
|
|
751
|
+
*
|
|
752
|
+
* Text nodes always require a parent, and they never have children.
|
|
753
|
+
* @param context The Expression Context.
|
|
754
|
+
* @param template The template, that contains the node value to be written.
|
|
755
|
+
* @param output The output.
|
|
756
|
+
*/
|
|
757
|
+
private commonLogicTextNode;
|
|
758
|
+
/**
|
|
759
|
+
* Passes template text to the output. The current template node does
|
|
760
|
+
* not specify an XSL-T operation and therefore is appended to the
|
|
761
|
+
* output with all its attributes. Then continues traversing the
|
|
762
|
+
* template node tree.
|
|
763
|
+
* @param context The Expression Context.
|
|
764
|
+
* @param template The XSLT stylesheet or transformation.
|
|
765
|
+
* @param output The output.
|
|
766
|
+
*/
|
|
767
|
+
protected xsltPassThrough(context: ExprContext, template: XNode, output: XNode): Promise<void>;
|
|
768
|
+
/**
|
|
769
|
+
* Determines if a text node in the XSLT template document is to be
|
|
770
|
+
* stripped according to XSLT whitespace stripping rules.
|
|
771
|
+
* @see [XSLT], section 3.4.
|
|
772
|
+
* @param template The XSLT template.
|
|
773
|
+
* @returns TODO
|
|
774
|
+
* @todo Whitespace stripping on the input document is
|
|
775
|
+
* currently not implemented.
|
|
776
|
+
*/
|
|
777
|
+
protected xsltPassText(template: XNode): boolean;
|
|
778
|
+
protected findAttributeInContext(attributeName: string, context: ExprContext): XNode;
|
|
779
|
+
/**
|
|
780
|
+
* Evaluates an XSL-T attribute value template. Attribute value
|
|
781
|
+
* templates are attributes on XSL-T elements that contain XPath
|
|
782
|
+
* expressions in braces {}. The XSL-T expressions are evaluated in
|
|
783
|
+
* the current input context.
|
|
784
|
+
* @param value TODO
|
|
785
|
+
* @param context TODO
|
|
786
|
+
* @returns TODO
|
|
787
|
+
*/
|
|
788
|
+
protected xsltAttributeValue(value: any, context: ExprContext): any;
|
|
789
|
+
/**
|
|
790
|
+
* Evaluates an XPath expression in the current input context as a
|
|
791
|
+
* match.
|
|
792
|
+
* @see [XSLT] section 5.2, paragraph 1
|
|
793
|
+
* @param match TODO
|
|
794
|
+
* @param context The Expression Context.
|
|
795
|
+
* @param axis The XPath axis. Used when the match does not start with the parent.
|
|
796
|
+
* @returns {XNode[]} A list of the found nodes.
|
|
797
|
+
*/
|
|
798
|
+
protected xsltMatch(match: string, context: ExprContext, axis?: string): XNode[];
|
|
799
|
+
/**
|
|
800
|
+
* Sets parameters defined by xsl:with-param child nodes of the
|
|
801
|
+
* current template node, in the current input context. This happens
|
|
802
|
+
* before the operation specified by the current template node is
|
|
803
|
+
* executed.
|
|
804
|
+
* @param context The Expression Context.
|
|
805
|
+
* @param template The template node.
|
|
806
|
+
*/
|
|
807
|
+
protected xsltWithParam(context: ExprContext, template: XNode): Promise<void>;
|
|
808
|
+
/**
|
|
809
|
+
* Test if the given element is an XSLT element, optionally the one with the given name.
|
|
810
|
+
* @param {XNode} element The element.
|
|
811
|
+
* @param {string} opt_wantedName The name for comparison.
|
|
812
|
+
* @returns True, if element is an XSL node. False otherwise.
|
|
813
|
+
*/
|
|
814
|
+
protected isXsltElement(element: XNode, opt_wantedName?: string): boolean;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
export { ExprContext, XPath, XmlParser, Xslt, type XsltOptions, xmlEscapeText };
|