xslt-processor 1.2.4 → 1.2.5

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.
Files changed (48) hide show
  1. package/package.json +1 -1
  2. package/umd/{xslt → xpath}/expr-context.d.ts +1 -1
  3. package/umd/xpath/expressions/binary-expr.d.ts +1 -1
  4. package/umd/xpath/expressions/function-call-expr.d.ts +1 -1
  5. package/umd/xpath/expressions/location-expr.d.ts +1 -1
  6. package/umd/xpath/expressions/step-expr.d.ts +1 -1
  7. package/umd/xpath/functions/non-standard.d.ts +1 -1
  8. package/umd/xpath/functions/standard.d.ts +1 -1
  9. package/umd/xpath/index.d.ts +1 -1
  10. package/umd/xpath/match-resolver.d.ts +55 -0
  11. package/umd/xpath/node-tests/node-test-comment.d.ts +1 -1
  12. package/umd/xpath/node-tests/node-test-element-or-attribute.d.ts +1 -1
  13. package/umd/xpath/node-tests/node-test-name.d.ts +1 -1
  14. package/umd/xpath/node-tests/node-test-nc.d.ts +1 -1
  15. package/umd/xpath/node-tests/node-test-pi.d.ts +1 -1
  16. package/umd/xpath/node-tests/node-test-text.d.ts +1 -1
  17. package/umd/xpath/node-tests/node-test.d.ts +1 -1
  18. package/umd/xpath/xpath.d.ts +1 -1
  19. package/umd/xslt/xslt.d.ts +10 -20
  20. package/umd/xslt-processor.js +2 -2
  21. package/umd/xslt-processor.js.map +1 -1
  22. package/{xslt → xpath}/expr-context.d.ts +1 -1
  23. package/{xslt → xpath}/expr-context.js +5 -5
  24. package/xpath/expr-context.js.map +1 -0
  25. package/xpath/expressions/binary-expr.d.ts +1 -1
  26. package/xpath/expressions/function-call-expr.d.ts +1 -1
  27. package/xpath/expressions/location-expr.d.ts +1 -1
  28. package/xpath/expressions/step-expr.d.ts +1 -1
  29. package/xpath/functions/non-standard.d.ts +1 -1
  30. package/xpath/functions/standard.d.ts +1 -1
  31. package/xpath/index.d.ts +1 -1
  32. package/xpath/index.js +1 -1
  33. package/xpath/index.js.map +1 -1
  34. package/xpath/match-resolver.d.ts +55 -0
  35. package/xpath/match-resolver.js +137 -0
  36. package/xpath/match-resolver.js.map +1 -0
  37. package/xpath/node-tests/node-test-comment.d.ts +1 -1
  38. package/xpath/node-tests/node-test-element-or-attribute.d.ts +1 -1
  39. package/xpath/node-tests/node-test-name.d.ts +1 -1
  40. package/xpath/node-tests/node-test-nc.d.ts +1 -1
  41. package/xpath/node-tests/node-test-pi.d.ts +1 -1
  42. package/xpath/node-tests/node-test-text.d.ts +1 -1
  43. package/xpath/node-tests/node-test.d.ts +1 -1
  44. package/xpath/xpath.d.ts +1 -1
  45. package/xslt/xslt.d.ts +10 -20
  46. package/xslt/xslt.js +40 -102
  47. package/xslt/xslt.js.map +1 -1
  48. package/xslt/expr-context.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { XNode } from '../dom';
2
- import { XsltDecimalFormatSettings } from './xslt-decimal-format-settings';
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("../xpath/values/boolean-value");
6
- var node_set_value_1 = require("../xpath/values/node-set-value");
7
- var number_value_1 = require("../xpath/values/number-value");
8
- var string_value_1 = require("../xpath/values/string-value");
9
- var tokens_1 = require("../xpath/tokens");
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,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A7B;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 "../../xslt/expr-context";
1
+ import { ExprContext } from "../expr-context";
2
2
  import { BooleanValue } from "../values/boolean-value";
3
3
  import { Expression } from "./expression";
4
4
  export declare class BinaryExpr extends Expression {
@@ -1,4 +1,4 @@
1
- import { ExprContext } from '../../xslt/expr-context';
1
+ import { ExprContext } from '../expr-context';
2
2
  import { Expression } from './expression';
3
3
  export declare class FunctionCallExpr extends Expression {
4
4
  name: any;
@@ -1,4 +1,4 @@
1
- import { ExprContext } from "../../xslt/expr-context";
1
+ import { ExprContext } from "../expr-context";
2
2
  import { NodeSetValue } from "../values/node-set-value";
3
3
  import { Expression } from "./expression";
4
4
  import { XPath } from "../xpath";
@@ -1,4 +1,4 @@
1
- import { ExprContext } from '../../xslt/expr-context';
1
+ import { ExprContext } from '../expr-context';
2
2
  import { NodeSetValue } from '../values/node-set-value';
3
3
  import { Expression } from './expression';
4
4
  import { XPath } from '../xpath';
@@ -1,4 +1,4 @@
1
- import { ExprContext } from "../../xslt/expr-context";
1
+ import { ExprContext } from "../expr-context";
2
2
  import { NodeSetValue, StringValue } from "../values";
3
3
  export declare function extCardinal(context: ExprContext): NodeSetValue;
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { ExprContext } from "../../xslt/expr-context";
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
@@ -1,3 +1,3 @@
1
- export * from '../xslt/expr-context';
1
+ export * from './expr-context';
2
2
  export * from './xpath';
3
3
  export * from './xpath-token-rule';
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("../xslt/expr-context"), exports);
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/xpath/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,0CAAwB;AACxB,qDAAmC"}
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,EA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AC,CAAC,CAAC,CAAC,CAAC;SAClD;aAAM;YACH,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;SAC/B;QAED,KAAoB,UAAY,EAAZ,6BAAY,EAAZ,0BAAY,EAAZ,IAAY,EAAE;YAA7B,IAAI,OAAO,qBAAA;YACZ,IAAI,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE;gBAC9C,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACxB,SAAS;aACZ;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAED;;;;;;;OAOG;IACK,yCAAiB,GAAzB,UAA0B,UAAwB,EAAE,OAAoB;QACpE,gEAAgE;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 "../../xslt/expr-context";
1
+ import { ExprContext } from "../expr-context";
2
2
  import { NodeTest } from "./node-test";
3
3
  import { BooleanValue } from "../values/boolean-value";
4
4
  export declare class NodeTestComment implements NodeTest {
@@ -1,4 +1,4 @@
1
- import { ExprContext } from "../../xslt/expr-context";
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 {
@@ -1,4 +1,4 @@
1
- import { ExprContext } from "../../xslt/expr-context";
1
+ import { ExprContext } from "../expr-context";
2
2
  import { NodeValue } from "../values";
3
3
  import { NodeTest } from "./node-test";
4
4
  export declare class NodeTestName implements NodeTest {
@@ -1,4 +1,4 @@
1
- import { ExprContext } from "../../xslt/expr-context";
1
+ import { ExprContext } from "../expr-context";
2
2
  import { NodeTest } from "./node-test";
3
3
  import { BooleanValue } from "../values/boolean-value";
4
4
  export declare class NodeTestNC implements NodeTest {
@@ -1,4 +1,4 @@
1
- import { ExprContext } from "../../xslt/expr-context";
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 NodeTestPI implements NodeTest {
@@ -1,4 +1,4 @@
1
- import { ExprContext } from "../../xslt/expr-context";
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 NodeTestText implements NodeTest {
@@ -1,4 +1,4 @@
1
- import { ExprContext } from "../../xslt/expr-context";
1
+ import { ExprContext } from "../expr-context";
2
2
  import { NodeValue } from "../values";
3
3
  export interface NodeTest {
4
4
  evaluate(_ctx: ExprContext): NodeValue;
package/xpath/xpath.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ExprContext } from '../xslt/expr-context';
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;
@@ -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
@@ -119,6 +120,14 @@ export declare class Xslt {
119
120
  * @param output The XML output.
120
121
  */
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.
129
+ */
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
package/xslt/xslt.js CHANGED
@@ -14,7 +14,7 @@ var dom_1 = require("../dom");
14
14
  var xpath_1 = require("../xpath");
15
15
  var constants_1 = require("../constants");
16
16
  var values_1 = require("../xpath/values");
17
- var expressions_1 = require("../xpath/expressions");
17
+ var match_resolver_1 = require("../xpath/match-resolver");
18
18
  /**
19
19
  * The main class for XSL-T processing. The implementation is NOT
20
20
  * complete; some xsl element are left out.
@@ -47,6 +47,7 @@ var Xslt = /** @class */ (function () {
47
47
  parameters: []
48
48
  }; }
49
49
  this.xPath = new xpath_1.XPath();
50
+ this.matchResolver = new match_resolver_1.MatchResolver();
50
51
  this.options = {
51
52
  escape: options.escape || true,
52
53
  selfClosingTags: options.selfClosingTags || true,
@@ -84,12 +85,12 @@ var Xslt = /** @class */ (function () {
84
85
  }
85
86
  }
86
87
  this.xsltProcessContext(expressionContext, stylesheet, outputDocument);
87
- var ret = (0, dom_1.xmlTransformedText)(outputDocument, {
88
+ var transformedOutputXml = (0, dom_1.xmlTransformedText)(outputDocument, {
88
89
  cData: false,
89
90
  escape: this.options.escape,
90
91
  selfClosingTags: this.options.selfClosingTags
91
92
  });
92
- return ret;
93
+ return transformedOutputXml;
93
94
  };
94
95
  /**
95
96
  * The main entry point of the XSL-T processor, as explained on the top of the file.
@@ -141,12 +142,21 @@ var Xslt = /** @class */ (function () {
141
142
  var modifiedContext = context.clone(nodes);
142
143
  for (var i = 0; i < templates.length; ++i) {
143
144
  for (var j = 0; j < modifiedContext.contextSize(); ++j) {
144
- var clonedContext_1 = modifiedContext.clone([modifiedContext.nodeList[j]], undefined, 0, undefined);
145
- clonedContext_1.inApplyTemplates = true;
146
- // The output depth should be restarted, since
147
- // another template is being applied from this point.
148
- clonedContext_1.outputDepth = 0;
149
- this.xsltProcessContext(clonedContext_1, templates[i], output);
145
+ // If the current node is text, there's no need to test all the templates
146
+ // against it. Just appending it to its parent is fine.
147
+ if (modifiedContext.nodeList[j].nodeType === constants_1.DOM_TEXT_NODE) {
148
+ var textNodeContext = context.clone([modifiedContext.nodeList[j]], undefined, 0, undefined);
149
+ // TODO: verify if it is okay to pass the own text node as template.
150
+ this.commonLogicTextNode(textNodeContext, modifiedContext.nodeList[j]);
151
+ }
152
+ else {
153
+ var clonedContext_1 = modifiedContext.clone([modifiedContext.nodeList[j]], undefined, 0, undefined);
154
+ clonedContext_1.inApplyTemplates = true;
155
+ // The output depth should be restarted, since
156
+ // another template is being applied from this point.
157
+ clonedContext_1.outputDepth = 0;
158
+ this.xsltProcessContext(clonedContext_1, templates[i], output);
159
+ }
150
160
  }
151
161
  }
152
162
  break;
@@ -441,22 +451,6 @@ var Xslt = /** @class */ (function () {
441
451
  for (var i = 0; i < sortContext.contextSize(); ++i) {
442
452
  this.xsltChildNodes(sortContext.clone(sortContext.nodeList, undefined, i), template, output);
443
453
  }
444
- // TODO: group nodes by parent node.
445
- // const nodeGroups = this.groupBy(nodes, 'parentNode');
446
- /* for (let [group, _nodes] of Object.entries(nodeGroups)) {
447
- const sortContext = context.clone(_nodes, 0);
448
- this.xsltSort(sortContext, template);
449
-
450
- for (let i = 0; i < sortContext.contextSize(); ++i) {
451
- this.xsltChildNodes(sortContext.clone(sortContext.nodeList, i), template, output);
452
- }
453
- } */
454
- };
455
- Xslt.prototype.groupBy = function (xs, key) {
456
- return xs.reduce(function (rv, x) {
457
- (rv[x[key]] = rv[x[key]] || []).push(x);
458
- return rv;
459
- }, {});
460
454
  };
461
455
  /**
462
456
  * Orders the current node list in the input context according to the
@@ -562,6 +556,25 @@ var Xslt = /** @class */ (function () {
562
556
  this.xsltProcessContext(contextClone, template.childNodes[i], output);
563
557
  }
564
558
  };
559
+ /**
560
+ * This logic is used in two different places:
561
+ * - `xsltPassThrough`, if the template asks this library to write a text node;
562
+ * - `xsltProcessContext`, `apply-templates` operation, when the current node is text.
563
+ * @param context The Expression Context.
564
+ * @param template The template, that contains the node value to be written.
565
+ */
566
+ Xslt.prototype.commonLogicTextNode = function (context, template) {
567
+ var textNodeList = context.outputNodeList[context.outputPosition].transformedChildNodes.filter(function (n) { return n.nodeType === constants_1.DOM_TEXT_NODE; });
568
+ if (textNodeList.length > 0) {
569
+ var node = textNodeList[0];
570
+ node.transformedNodeValue = template.nodeValue;
571
+ }
572
+ else {
573
+ var node = (0, dom_1.domCreateTransformedTextNode)(this.outputDocument, template.nodeValue);
574
+ node.transformedParentNode = context.outputNodeList[context.outputPosition];
575
+ (0, dom_1.domAppendTransformedChild)(context.outputNodeList[context.outputPosition], node);
576
+ }
577
+ };
565
578
  /**
566
579
  * Passes template text to the output. The current template node does
567
580
  * not specify an XSL-T operation and therefore is appended to the
@@ -574,21 +587,11 @@ var Xslt = /** @class */ (function () {
574
587
  Xslt.prototype.xsltPassThrough = function (context, template, output) {
575
588
  if (template.nodeType == constants_1.DOM_TEXT_NODE) {
576
589
  if (this.xsltPassText(template)) {
577
- var textNodeList = context.outputNodeList[context.outputPosition].transformedChildNodes.filter(function (n) { return n.nodeType === constants_1.DOM_TEXT_NODE; });
578
- if (textNodeList.length > 0) {
579
- var node = textNodeList[0];
580
- node.transformedNodeValue = template.nodeValue;
581
- }
582
- else {
583
- var node = (0, dom_1.domCreateTransformedTextNode)(this.outputDocument, template.nodeValue);
584
- node.transformedParentNode = context.outputNodeList[context.outputPosition];
585
- (0, dom_1.domAppendTransformedChild)(context.outputNodeList[context.outputPosition], node);
586
- }
590
+ this.commonLogicTextNode(context, template);
587
591
  }
588
592
  }
589
593
  else if (template.nodeType == constants_1.DOM_ELEMENT_NODE) {
590
594
  var node = void 0;
591
- // let node = domCreateElement(outputDocument, template.nodeName);
592
595
  var elementContext = context;
593
596
  if (context.nodeList[context.position].nodeName === '#document') {
594
597
  node = context.nodeList[context.position].firstChild;
@@ -700,72 +703,7 @@ var Xslt = /** @class */ (function () {
700
703
  */
701
704
  Xslt.prototype.xsltMatch = function (match, context, axis) {
702
705
  var expression = this.xPath.xPathParse(match, axis);
703
- if (expression instanceof expressions_1.LocationExpr) {
704
- return this.xsltLocationExpressionMatch(expression, context);
705
- }
706
- if (expression instanceof expressions_1.UnionExpr) {
707
- // TODO: What about if `expr1` and `expr2` are not `LocationExpr`?
708
- return (this.xsltLocationExpressionMatch(expression.expr1, context) ||
709
- this.xsltLocationExpressionMatch(expression.expr2, context));
710
- }
711
- // TODO: Other expressions
712
- return [];
713
- };
714
- Xslt.prototype.xsltLocationExpressionMatch = function (expression, context) {
715
- if (expression === undefined || expression.steps === undefined || expression.steps.length <= 0) {
716
- throw new Error('Error resolving XSLT match: Location Expression should have steps.');
717
- }
718
- if (expression.absolute) {
719
- return this.absoluteXsltMatch(expression, context);
720
- }
721
- return this.relativeXsltMatch(expression, context);
722
- };
723
- /**
724
- * Finds all the nodes through absolute xPath search.
725
- * Returns only nodes that match either the context position node,
726
- * or an ancestor.
727
- * @param expression The Expression.
728
- * @param context The Expression Context.
729
- * @returns The list of found nodes.
730
- */
731
- Xslt.prototype.absoluteXsltMatch = function (expression, context) {
732
- var clonedContext = context.clone([context.root], undefined, 0, undefined);
733
- var matchedNodes = expression.evaluate(clonedContext).nodeSetValue();
734
- var finalList = [];
735
- for (var _i = 0, matchedNodes_1 = matchedNodes; _i < matchedNodes_1.length; _i++) {
736
- var element = matchedNodes_1[_i];
737
- if (element.id === context.nodeList[context.position].id) {
738
- finalList.push(element);
739
- continue;
740
- }
741
- if (element.getAncestorById(context.nodeList[context.position].id) !== undefined) {
742
- finalList.push(element);
743
- }
744
- }
745
- return finalList;
746
- };
747
- /**
748
- * Tries to find relative nodes from the actual context position.
749
- * If found nodes are already in the context, or if they are children of
750
- * nodes in the context, they are returned.
751
- * @param expression The expression used.
752
- * @param context The Expression Context.
753
- * @returns The list of found nodes.
754
- */
755
- Xslt.prototype.relativeXsltMatch = function (expression, context) {
756
- // For some reason, XPath understands a default as 'child axis'.
757
- // There's no "self + siblings" axis, so what is expected at this point
758
- // is to have in the expression context the parent that should
759
- // have the nodes we are interested in.
760
- var clonedContext = context.clone();
761
- var nodes = expression.evaluate(clonedContext).nodeSetValue();
762
- if (nodes.length === 1 && nodes[0].nodeName === '#document') {
763
- // As we don't work with the #document node directly, this part
764
- // returns its first sibling.
765
- // By the way, it should be *always* one sibling here.
766
- return [nodes[0].childNodes[0]];
767
- }
768
- return nodes;
706
+ return this.matchResolver.expressionMatch(expression, context);
769
707
  };
770
708
  /**
771
709
  * Sets parameters defined by xsl:with-param child nodes of the