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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xslt-processor",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "A JavaScript XSLT Processor",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -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
@@ -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;
@@ -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';
@@ -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
+ }
@@ -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;
@@ -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';
@@ -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