xslt-processor 1.2.4 → 1.2.6
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/dom/functions.js +15 -15
- package/dom/functions.js.map +1 -1
- package/dom/xnode.d.ts +3 -3
- package/dom/xnode.js +4 -1
- package/dom/xnode.js.map +1 -1
- package/package.json +1 -1
- package/umd/dom/xnode.d.ts +3 -3
- package/umd/{xslt → xpath}/expr-context.d.ts +1 -1
- package/umd/xpath/expressions/binary-expr.d.ts +1 -1
- package/umd/xpath/expressions/function-call-expr.d.ts +1 -1
- package/umd/xpath/expressions/location-expr.d.ts +1 -1
- package/umd/xpath/expressions/step-expr.d.ts +1 -1
- package/umd/xpath/functions/non-standard.d.ts +1 -1
- package/umd/xpath/functions/standard.d.ts +1 -1
- package/umd/xpath/index.d.ts +1 -1
- package/umd/xpath/match-resolver.d.ts +55 -0
- package/umd/xpath/node-tests/node-test-comment.d.ts +1 -1
- package/umd/xpath/node-tests/node-test-element-or-attribute.d.ts +1 -1
- package/umd/xpath/node-tests/node-test-name.d.ts +1 -1
- package/umd/xpath/node-tests/node-test-nc.d.ts +1 -1
- package/umd/xpath/node-tests/node-test-pi.d.ts +1 -1
- package/umd/xpath/node-tests/node-test-text.d.ts +1 -1
- package/umd/xpath/node-tests/node-test.d.ts +1 -1
- package/umd/xpath/xpath.d.ts +1 -1
- package/umd/xslt/xslt.d.ts +18 -28
- package/umd/xslt-processor.js +2 -2
- package/umd/xslt-processor.js.map +1 -1
- package/{xslt → xpath}/expr-context.d.ts +1 -1
- package/{xslt → xpath}/expr-context.js +5 -5
- package/xpath/expr-context.js.map +1 -0
- package/xpath/expressions/binary-expr.d.ts +1 -1
- package/xpath/expressions/function-call-expr.d.ts +1 -1
- package/xpath/expressions/location-expr.d.ts +1 -1
- package/xpath/expressions/step-expr.d.ts +1 -1
- package/xpath/functions/non-standard.d.ts +1 -1
- package/xpath/functions/standard.d.ts +1 -1
- package/xpath/index.d.ts +1 -1
- package/xpath/index.js +1 -1
- package/xpath/index.js.map +1 -1
- package/xpath/match-resolver.d.ts +55 -0
- package/xpath/match-resolver.js +137 -0
- package/xpath/match-resolver.js.map +1 -0
- package/xpath/node-tests/node-test-comment.d.ts +1 -1
- package/xpath/node-tests/node-test-element-or-attribute.d.ts +1 -1
- package/xpath/node-tests/node-test-name.d.ts +1 -1
- package/xpath/node-tests/node-test-nc.d.ts +1 -1
- package/xpath/node-tests/node-test-pi.d.ts +1 -1
- package/xpath/node-tests/node-test-text.d.ts +1 -1
- package/xpath/node-tests/node-test.d.ts +1 -1
- package/xpath/xpath.d.ts +1 -1
- package/xslt/xslt.d.ts +18 -28
- package/xslt/xslt.js +91 -127
- package/xslt/xslt.js.map +1 -1
- package/xslt/expr-context.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XNode } from '../dom';
|
|
2
|
-
import { XsltDecimalFormatSettings } from '
|
|
2
|
+
import { XsltDecimalFormatSettings } from '../xslt/xslt-decimal-format-settings';
|
|
3
3
|
/** XPath expression evaluation context. An XPath context consists of a
|
|
4
4
|
* DOM node, a list of DOM nodes that contains this node, a number
|
|
5
5
|
* that represents the position of the single node in the list, and a
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExprContext = void 0;
|
|
4
4
|
var constants_1 = require("../constants");
|
|
5
|
-
var boolean_value_1 = require("
|
|
6
|
-
var node_set_value_1 = require("
|
|
7
|
-
var number_value_1 = require("
|
|
8
|
-
var string_value_1 = require("
|
|
9
|
-
var tokens_1 = require("
|
|
5
|
+
var boolean_value_1 = require("./values/boolean-value");
|
|
6
|
+
var node_set_value_1 = require("./values/node-set-value");
|
|
7
|
+
var number_value_1 = require("./values/number-value");
|
|
8
|
+
var string_value_1 = require("./values/string-value");
|
|
9
|
+
var tokens_1 = require("./tokens");
|
|
10
10
|
/** XPath expression evaluation context. An XPath context consists of a
|
|
11
11
|
* DOM node, a list of DOM nodes that contains this node, a number
|
|
12
12
|
* that represents the position of the single node in the list, and a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expr-context.js","sourceRoot":"","sources":["../../src/xpath/expr-context.ts"],"names":[],"mappings":";;;AAAA,0CAAiD;AACjD,wDAAsD;AACtD,0DAAuD;AACvD,sDAAoD;AACpD,sDAAoD;AACpD,mCAAsC;AAItC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH;IAsBI;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,qBACI,QAAiB,EACjB,cAAuB,EACvB,YAAqB,EACrB,kBAA2B,EAC3B,eAAwB,EACxB,yBAAqD,EACrD,aAAuC,EACvC,mBAAiD,EACjD,UAAwB,EACxB,mBAAyB,EACzB,gCAAsC,EACtC,sBAA4B,EAC5B,+BAAqC;QAErC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,YAAY,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,kBAAkB,IAAI,CAAC,CAAC;QAE9C,IAAI,CAAC,SAAS,GAAG,aAAa,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,mBAAmB,IAAI,EAAE,CAAC;QAEjD,IAAI,CAAC,MAAM,GAAG,UAAU,IAAI,IAAI,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,mBAAmB,IAAI,KAAK,CAAC;QACpD,IAAI,CAAC,4BAA4B,GAAG,gCAAgC,IAAI,KAAK,CAAC;QAC9E,IAAI,CAAC,kBAAkB,GAAG,sBAAsB,IAAI,KAAK,CAAC;QAC1D,IAAI,CAAC,2BAA2B,GAAG,+BAA+B,IAAI,KAAK,CAAC;QAC5E,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;QACj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,kBAAkB;QACpC,OAAO,CAAC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC,CAAC;IAC1D,CAAC;IAED,mDAA6B,GAA7B;QACI,OAAO,IAAI,CAAC,2BAA2B,CAAC;IAC5C,CAAC;IAED,oDAA8B,GAA9B,UAA+B,2BAA2B;QACtD,OAAO,CAAC,IAAI,CAAC,2BAA2B,GAAG,2BAA2B,CAAC,CAAC;IAC5E,CAAC;IACL,kBAAC;AAAD,CAAC,AA7ND,IA6NC;AA7NY,kCAAW"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExprContext } from "
|
|
1
|
+
import { ExprContext } from "../expr-context";
|
|
2
2
|
import { BooleanValue, NodeSetValue, NumberValue, StringValue } from "../values";
|
|
3
3
|
export declare function boolean(context: ExprContext): BooleanValue;
|
|
4
4
|
export declare function ceiling(context: ExprContext): NumberValue;
|
package/xpath/index.d.ts
CHANGED
package/xpath/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("
|
|
17
|
+
__exportStar(require("./expr-context"), exports);
|
|
18
18
|
__exportStar(require("./xpath"), exports);
|
|
19
19
|
__exportStar(require("./xpath-token-rule"), exports);
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
package/xpath/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/xpath/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/xpath/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,0CAAwB;AACxB,qDAAmC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { XNode } from "../dom";
|
|
2
|
+
import { ExprContext } from "./expr-context";
|
|
3
|
+
import { Expression } from "./expressions/expression";
|
|
4
|
+
/**
|
|
5
|
+
* Class that resolves XPath expressions, returning nodes.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MatchResolver {
|
|
8
|
+
/**
|
|
9
|
+
* This class entry point.
|
|
10
|
+
* @param expression The expression to be resolved.
|
|
11
|
+
* @param context The Expression Context
|
|
12
|
+
* @returns An array of nodes.
|
|
13
|
+
*/
|
|
14
|
+
expressionMatch(expression: Expression, context: ExprContext): XNode[];
|
|
15
|
+
/**
|
|
16
|
+
* Resolves a `LocationExpr`.
|
|
17
|
+
* @param expression The Location Expression.
|
|
18
|
+
* @param context The Expression Context.
|
|
19
|
+
* @returns Either the results of a relative resolution, or the results of an
|
|
20
|
+
* absolute resolution.
|
|
21
|
+
*/
|
|
22
|
+
private locationExpressionMatch;
|
|
23
|
+
/**
|
|
24
|
+
* Resolves a `UnionExpr`.
|
|
25
|
+
* @param expression The Union Expression.
|
|
26
|
+
* @param context The Expression Context.
|
|
27
|
+
* @returns The concatenated result of evaluating the both sides of the expression.
|
|
28
|
+
*/
|
|
29
|
+
private unionExpressionMatch;
|
|
30
|
+
/**
|
|
31
|
+
* Finds all the nodes through absolute XPath search, starting on
|
|
32
|
+
* the #document parent node.
|
|
33
|
+
* @param expression The Expression.
|
|
34
|
+
* @param context The Expression Context.
|
|
35
|
+
* @returns The list of found nodes.
|
|
36
|
+
*/
|
|
37
|
+
private absoluteXsltMatchByDocumentNode;
|
|
38
|
+
/**
|
|
39
|
+
* Finds all the nodes through absolute xPath search, starting with the
|
|
40
|
+
* first child of the #document node.
|
|
41
|
+
* @param expression The Expression.
|
|
42
|
+
* @param context The Expression Context.
|
|
43
|
+
* @returns The list of found nodes.
|
|
44
|
+
*/
|
|
45
|
+
private absoluteXsltMatch;
|
|
46
|
+
/**
|
|
47
|
+
* Tries to find relative nodes from the actual context position.
|
|
48
|
+
* If found nodes are already in the context, or if they are children of
|
|
49
|
+
* nodes in the context, they are returned.
|
|
50
|
+
* @param expression The expression used.
|
|
51
|
+
* @param context The Expression Context.
|
|
52
|
+
* @returns The list of found nodes.
|
|
53
|
+
*/
|
|
54
|
+
private relativeXsltMatch;
|
|
55
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MatchResolver = void 0;
|
|
4
|
+
var expressions_1 = require("./expressions");
|
|
5
|
+
/**
|
|
6
|
+
* Class that resolves XPath expressions, returning nodes.
|
|
7
|
+
*/
|
|
8
|
+
var MatchResolver = /** @class */ (function () {
|
|
9
|
+
function MatchResolver() {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* This class entry point.
|
|
13
|
+
* @param expression The expression to be resolved.
|
|
14
|
+
* @param context The Expression Context
|
|
15
|
+
* @returns An array of nodes.
|
|
16
|
+
*/
|
|
17
|
+
MatchResolver.prototype.expressionMatch = function (expression, context) {
|
|
18
|
+
if (expression instanceof expressions_1.LocationExpr) {
|
|
19
|
+
return this.locationExpressionMatch(expression, context);
|
|
20
|
+
}
|
|
21
|
+
if (expression instanceof expressions_1.UnionExpr) {
|
|
22
|
+
return this.unionExpressionMatch(expression, context);
|
|
23
|
+
}
|
|
24
|
+
// TODO: Other expressions
|
|
25
|
+
return [];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Resolves a `LocationExpr`.
|
|
29
|
+
* @param expression The Location Expression.
|
|
30
|
+
* @param context The Expression Context.
|
|
31
|
+
* @returns Either the results of a relative resolution, or the results of an
|
|
32
|
+
* absolute resolution.
|
|
33
|
+
*/
|
|
34
|
+
MatchResolver.prototype.locationExpressionMatch = function (expression, context) {
|
|
35
|
+
if (expression === undefined || expression.steps === undefined || expression.steps.length <= 0) {
|
|
36
|
+
throw new Error('Error resolving XSLT match: Location Expression should have steps.');
|
|
37
|
+
}
|
|
38
|
+
if (expression.absolute) {
|
|
39
|
+
// If expression is absolute and the axis of first step is self,
|
|
40
|
+
// the match starts by the #document node (for instance, `<xsl:template match="/">`).
|
|
41
|
+
// Otherwise (axis === 'child'), the match stasts on the first
|
|
42
|
+
// child of #document node.
|
|
43
|
+
var firstStep = expression.steps[0];
|
|
44
|
+
if (firstStep.axis === 'self') {
|
|
45
|
+
return this.absoluteXsltMatchByDocumentNode(expression, context);
|
|
46
|
+
}
|
|
47
|
+
return this.absoluteXsltMatch(expression, context);
|
|
48
|
+
}
|
|
49
|
+
return this.relativeXsltMatch(expression, context);
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Resolves a `UnionExpr`.
|
|
53
|
+
* @param expression The Union Expression.
|
|
54
|
+
* @param context The Expression Context.
|
|
55
|
+
* @returns The concatenated result of evaluating the both sides of the expression.
|
|
56
|
+
*/
|
|
57
|
+
MatchResolver.prototype.unionExpressionMatch = function (expression, context) {
|
|
58
|
+
var expr1Nodes = this.expressionMatch(expression.expr1, context);
|
|
59
|
+
return expr1Nodes.concat(this.expressionMatch(expression.expr2, context));
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Finds all the nodes through absolute XPath search, starting on
|
|
63
|
+
* the #document parent node.
|
|
64
|
+
* @param expression The Expression.
|
|
65
|
+
* @param context The Expression Context.
|
|
66
|
+
* @returns The list of found nodes.
|
|
67
|
+
*/
|
|
68
|
+
MatchResolver.prototype.absoluteXsltMatchByDocumentNode = function (expression, context) {
|
|
69
|
+
var clonedContext = context.clone([context.root], undefined, 0, undefined);
|
|
70
|
+
var matchedNodes = expression.evaluate(clonedContext).nodeSetValue();
|
|
71
|
+
var finalList = [];
|
|
72
|
+
for (var _i = 0, matchedNodes_1 = matchedNodes; _i < matchedNodes_1.length; _i++) {
|
|
73
|
+
var element = matchedNodes_1[_i];
|
|
74
|
+
if (element.id === context.nodeList[context.position].id) {
|
|
75
|
+
finalList.push(element);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return finalList;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Finds all the nodes through absolute xPath search, starting with the
|
|
83
|
+
* first child of the #document node.
|
|
84
|
+
* @param expression The Expression.
|
|
85
|
+
* @param context The Expression Context.
|
|
86
|
+
* @returns The list of found nodes.
|
|
87
|
+
*/
|
|
88
|
+
MatchResolver.prototype.absoluteXsltMatch = function (expression, context) {
|
|
89
|
+
var firstChildOfRoot = context.root.childNodes[0];
|
|
90
|
+
var clonedContext = context.clone([firstChildOfRoot], undefined, 0, undefined);
|
|
91
|
+
var matchedNodes = expression.evaluate(clonedContext).nodeSetValue();
|
|
92
|
+
var finalList = [];
|
|
93
|
+
// If the context is pointing to #document node, it's child node is
|
|
94
|
+
// considered.
|
|
95
|
+
var nodeList;
|
|
96
|
+
if (context.nodeList.length === 1 && context.nodeList[0].nodeName === '#document') {
|
|
97
|
+
nodeList = [context.nodeList[0].childNodes[0]];
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
nodeList = context.nodeList;
|
|
101
|
+
}
|
|
102
|
+
for (var _i = 0, matchedNodes_2 = matchedNodes; _i < matchedNodes_2.length; _i++) {
|
|
103
|
+
var element = matchedNodes_2[_i];
|
|
104
|
+
if (element.id === nodeList[context.position].id) {
|
|
105
|
+
finalList.push(element);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return finalList;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Tries to find relative nodes from the actual context position.
|
|
113
|
+
* If found nodes are already in the context, or if they are children of
|
|
114
|
+
* nodes in the context, they are returned.
|
|
115
|
+
* @param expression The expression used.
|
|
116
|
+
* @param context The Expression Context.
|
|
117
|
+
* @returns The list of found nodes.
|
|
118
|
+
*/
|
|
119
|
+
MatchResolver.prototype.relativeXsltMatch = function (expression, context) {
|
|
120
|
+
// For some reason, XPath understands a default as 'child axis'.
|
|
121
|
+
// There's no "self + siblings" axis, so what is expected at this point
|
|
122
|
+
// is to have in the expression context the parent that should
|
|
123
|
+
// have the nodes we are interested in.
|
|
124
|
+
var clonedContext = context.clone();
|
|
125
|
+
var nodes = expression.evaluate(clonedContext).nodeSetValue();
|
|
126
|
+
if (nodes.length === 1 && nodes[0].nodeName === '#document') {
|
|
127
|
+
// As we don't work with the #document node directly, this part
|
|
128
|
+
// returns its first sibling.
|
|
129
|
+
// By the way, it should be *always* one sibling here.
|
|
130
|
+
return [nodes[0].childNodes[0]];
|
|
131
|
+
}
|
|
132
|
+
return nodes;
|
|
133
|
+
};
|
|
134
|
+
return MatchResolver;
|
|
135
|
+
}());
|
|
136
|
+
exports.MatchResolver = MatchResolver;
|
|
137
|
+
//# sourceMappingURL=match-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-resolver.js","sourceRoot":"","sources":["../../src/xpath/match-resolver.ts"],"names":[],"mappings":";;;AAEA,6CAAwD;AAGxD;;GAEG;AACH;IAAA;IA2IA,CAAC;IAzIG;;;;;OAKG;IACH,uCAAe,GAAf,UAAgB,UAAsB,EAAE,OAAoB;QACxD,IAAI,UAAU,YAAY,0BAAY,EAAE;YACpC,OAAO,IAAI,CAAC,uBAAuB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;SAC5D;QAED,IAAI,UAAU,YAAY,uBAAS,EAAE;YACjC,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;SACzD;QAED,0BAA0B;QAC1B,OAAO,EAAE,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACK,+CAAuB,GAA/B,UAAgC,UAAwB,EAAE,OAAoB;QAC1E,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,EAAE;YAC5F,MAAM,IAAI,KAAK,CAAC,oEAAoE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E;QAChE,uEAAuE;QACvE,8DAA8D;QAC9D,uCAAuC;QAEvC,IAAM,aAAa,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;QACtC,IAAI,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,YAAY,EAAE,CAAC;QAC9D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,WAAW,EAAE;YACzD,+DAA+D;YAC/D,6BAA6B;YAC7B,sDAAsD;YACtD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;SACnC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IACL,oBAAC;AAAD,CAAC,AA3ID,IA2IC;AA3IY,sCAAa"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExprContext } from "
|
|
1
|
+
import { ExprContext } from "../expr-context";
|
|
2
2
|
import { BooleanValue } from "../values/boolean-value";
|
|
3
3
|
import { NodeTest } from "./node-test";
|
|
4
4
|
export declare class NodeTestElementOrAttribute implements NodeTest {
|
package/xpath/xpath.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExprContext } from '
|
|
1
|
+
import { ExprContext } from './expr-context';
|
|
2
2
|
import { BinaryExpr, FunctionCallExpr, LiteralExpr, LocationExpr, NumberExpr, PathExpr, PredicateExpr, StepExpr, TokenExpr, UnaryMinusExpr, UnionExpr, VariableExpr } from './expressions';
|
|
3
3
|
import { Expression } from './expressions/expression';
|
|
4
4
|
import { XPathTokenRule } from './xpath-token-rule';
|
package/xslt/xslt.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { XDocument, XNode } from '../dom';
|
|
|
2
2
|
import { ExprContext, XPath } from '../xpath';
|
|
3
3
|
import { XsltOptions } from './xslt-options';
|
|
4
4
|
import { XsltDecimalFormatSettings } from './xslt-decimal-format-settings';
|
|
5
|
+
import { MatchResolver } from '../xpath/match-resolver';
|
|
5
6
|
/**
|
|
6
7
|
* The main class for XSL-T processing. The implementation is NOT
|
|
7
8
|
* complete; some xsl element are left out.
|
|
@@ -28,6 +29,7 @@ import { XsltDecimalFormatSettings } from './xslt-decimal-format-settings';
|
|
|
28
29
|
*/
|
|
29
30
|
export declare class Xslt {
|
|
30
31
|
xPath: XPath;
|
|
32
|
+
matchResolver: MatchResolver;
|
|
31
33
|
options: XsltOptions;
|
|
32
34
|
decimalFormatSettings: XsltDecimalFormatSettings;
|
|
33
35
|
outputDocument: XDocument;
|
|
@@ -44,11 +46,11 @@ export declare class Xslt {
|
|
|
44
46
|
xsltProcess(xmlDoc: XDocument, stylesheet: XDocument): string;
|
|
45
47
|
/**
|
|
46
48
|
* The main entry point of the XSL-T processor, as explained on the top of the file.
|
|
47
|
-
* @param context The input document root, as XPath ExprContext
|
|
49
|
+
* @param context The input document root, as XPath `ExprContext`.
|
|
48
50
|
* @param template The stylesheet document root, as DOM node.
|
|
49
|
-
* @param output the
|
|
51
|
+
* @param output If set, the output where the transformation should occur.
|
|
50
52
|
*/
|
|
51
|
-
protected xsltProcessContext(context: ExprContext, template: XNode, output
|
|
53
|
+
protected xsltProcessContext(context: ExprContext, template: XNode, output?: XNode): void;
|
|
52
54
|
/**
|
|
53
55
|
* Implements xsl:choose and its child nodes xsl:when and
|
|
54
56
|
* xsl:otherwise.
|
|
@@ -68,10 +70,10 @@ export declare class Xslt {
|
|
|
68
70
|
* Implements `xsl:copy-of` for node-set values of the select
|
|
69
71
|
* expression. Recurses down the source node tree, which is part of
|
|
70
72
|
* the input document.
|
|
71
|
-
* @param {XNode}
|
|
72
|
-
* @param {XNode}
|
|
73
|
+
* @param {XNode} destination the node being copied to, part of output document.
|
|
74
|
+
* @param {XNode} source the node being copied, part in input document.
|
|
73
75
|
*/
|
|
74
|
-
protected xsltCopyOf(
|
|
76
|
+
protected xsltCopyOf(destination: XNode, source: XNode): void;
|
|
75
77
|
/**
|
|
76
78
|
* Implements `xsl:for-each`.
|
|
77
79
|
* @param input The Expression Context.
|
|
@@ -79,7 +81,6 @@ export declare class Xslt {
|
|
|
79
81
|
* @param output The output.
|
|
80
82
|
*/
|
|
81
83
|
protected xsltForEach(context: ExprContext, template: XNode, output: XNode): void;
|
|
82
|
-
protected groupBy(xs: any, key: any): any;
|
|
83
84
|
/**
|
|
84
85
|
* Orders the current node list in the input context according to the
|
|
85
86
|
* sort order specified by xsl:sort child nodes of the current
|
|
@@ -116,9 +117,17 @@ export declare class Xslt {
|
|
|
116
117
|
* current template node.
|
|
117
118
|
* @param context Normally the Expression Context.
|
|
118
119
|
* @param template The XSL-T definition.
|
|
119
|
-
* @param output
|
|
120
|
+
* @param output If set, the output where the transformation should occur.
|
|
121
|
+
*/
|
|
122
|
+
protected xsltChildNodes(context: ExprContext, template: XNode, output?: XNode): void;
|
|
123
|
+
/**
|
|
124
|
+
* This logic is used in two different places:
|
|
125
|
+
* - `xsltPassThrough`, if the template asks this library to write a text node;
|
|
126
|
+
* - `xsltProcessContext`, `apply-templates` operation, when the current node is text.
|
|
127
|
+
* @param context The Expression Context.
|
|
128
|
+
* @param template The template, that contains the node value to be written.
|
|
120
129
|
*/
|
|
121
|
-
|
|
130
|
+
private commonLogicTextNode;
|
|
122
131
|
/**
|
|
123
132
|
* Passes template text to the output. The current template node does
|
|
124
133
|
* not specify an XSL-T operation and therefore is appended to the
|
|
@@ -159,25 +168,6 @@ export declare class Xslt {
|
|
|
159
168
|
* @returns {XNode[]} A list of the found nodes.
|
|
160
169
|
*/
|
|
161
170
|
protected xsltMatch(match: string, context: ExprContext, axis?: string): XNode[];
|
|
162
|
-
private xsltLocationExpressionMatch;
|
|
163
|
-
/**
|
|
164
|
-
* Finds all the nodes through absolute xPath search.
|
|
165
|
-
* Returns only nodes that match either the context position node,
|
|
166
|
-
* or an ancestor.
|
|
167
|
-
* @param expression The Expression.
|
|
168
|
-
* @param context The Expression Context.
|
|
169
|
-
* @returns The list of found nodes.
|
|
170
|
-
*/
|
|
171
|
-
private absoluteXsltMatch;
|
|
172
|
-
/**
|
|
173
|
-
* Tries to find relative nodes from the actual context position.
|
|
174
|
-
* If found nodes are already in the context, or if they are children of
|
|
175
|
-
* nodes in the context, they are returned.
|
|
176
|
-
* @param expression The expression used.
|
|
177
|
-
* @param context The Expression Context.
|
|
178
|
-
* @returns The list of found nodes.
|
|
179
|
-
*/
|
|
180
|
-
private relativeXsltMatch;
|
|
181
171
|
/**
|
|
182
172
|
* Sets parameters defined by xsl:with-param child nodes of the
|
|
183
173
|
* current template node, in the current input context. This happens
|