xslt-processor 1.1.6 → 1.2.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.
Files changed (83) hide show
  1. package/dom/functions.d.ts +5 -5
  2. package/dom/functions.js +4 -3
  3. package/dom/functions.js.map +1 -1
  4. package/dom/util.d.ts +2 -21
  5. package/dom/util.js +3 -111
  6. package/dom/util.js.map +1 -1
  7. package/dom/xdocument.d.ts +9 -9
  8. package/dom/xdocument.js.map +1 -1
  9. package/dom/xml-functions.js +3 -2
  10. package/dom/xml-functions.js.map +1 -1
  11. package/dom/xnode.d.ts +8 -4
  12. package/dom/xnode.js +30 -11
  13. package/dom/xnode.js.map +1 -1
  14. package/package.json +1 -1
  15. package/umd/dom/functions.d.ts +5 -5
  16. package/umd/dom/util.d.ts +2 -21
  17. package/umd/dom/xdocument.d.ts +9 -9
  18. package/umd/dom/xnode.d.ts +8 -4
  19. package/umd/xpath/common-function.d.ts +8 -0
  20. package/umd/xpath/expr-context.d.ts +79 -6
  21. package/umd/xpath/expressions/function-call-expr.d.ts +3 -41
  22. package/umd/xpath/expressions/location-expr.d.ts +2 -1
  23. package/umd/xpath/expressions/step-expr.d.ts +16 -6
  24. package/umd/xpath/expressions/union-expr.d.ts +4 -4
  25. package/umd/xpath/functions/index.d.ts +2 -0
  26. package/umd/xpath/functions/internal-functions.d.ts +2 -0
  27. package/umd/xpath/functions/non-standard.d.ts +12 -0
  28. package/umd/xpath/functions/standard.d.ts +33 -0
  29. package/umd/xpath/tokens.d.ts +2 -1
  30. package/umd/xpath/xpath.d.ts +27 -12
  31. package/umd/xslt/xslt.d.ts +32 -18
  32. package/umd/xslt-processor.js +2 -2
  33. package/umd/xslt-processor.js.map +1 -1
  34. package/xpath/common-function.d.ts +8 -0
  35. package/xpath/common-function.js +33 -0
  36. package/xpath/common-function.js.map +1 -0
  37. package/xpath/expr-context.d.ts +79 -6
  38. package/xpath/expr-context.js +82 -59
  39. package/xpath/expr-context.js.map +1 -1
  40. package/xpath/expressions/filter-expr.js +1 -1
  41. package/xpath/expressions/filter-expr.js.map +1 -1
  42. package/xpath/expressions/function-call-expr.d.ts +3 -41
  43. package/xpath/expressions/function-call-expr.js +42 -346
  44. package/xpath/expressions/function-call-expr.js.map +1 -1
  45. package/xpath/expressions/location-expr.d.ts +2 -1
  46. package/xpath/expressions/location-expr.js +9 -9
  47. package/xpath/expressions/location-expr.js.map +1 -1
  48. package/xpath/expressions/path-expr.js +2 -2
  49. package/xpath/expressions/path-expr.js.map +1 -1
  50. package/xpath/expressions/step-expr.d.ts +16 -6
  51. package/xpath/expressions/step-expr.js +184 -113
  52. package/xpath/expressions/step-expr.js.map +1 -1
  53. package/xpath/expressions/union-expr.d.ts +4 -4
  54. package/xpath/expressions/union-expr.js +3 -3
  55. package/xpath/expressions/union-expr.js.map +1 -1
  56. package/xpath/functions/index.d.ts +2 -0
  57. package/xpath/functions/index.js +19 -0
  58. package/xpath/functions/index.js.map +1 -0
  59. package/xpath/functions/internal-functions.d.ts +2 -0
  60. package/xpath/functions/internal-functions.js +23 -0
  61. package/xpath/functions/internal-functions.js.map +1 -0
  62. package/xpath/functions/non-standard.d.ts +12 -0
  63. package/xpath/functions/non-standard.js +46 -0
  64. package/xpath/functions/non-standard.js.map +1 -0
  65. package/xpath/functions/standard.d.ts +33 -0
  66. package/xpath/functions/standard.js +345 -0
  67. package/xpath/functions/standard.js.map +1 -0
  68. package/xpath/node-test-element-or-attribute.js +1 -1
  69. package/xpath/node-test-name.js +1 -1
  70. package/xpath/tokens.d.ts +2 -1
  71. package/xpath/tokens.js +19 -17
  72. package/xpath/tokens.js.map +1 -1
  73. package/xpath/values/index.js +32 -0
  74. package/xpath/values/index.js.map +1 -1
  75. package/xpath/values/string-value.js +0 -32
  76. package/xpath/values/string-value.js.map +1 -1
  77. package/xpath/xpath.d.ts +27 -12
  78. package/xpath/xpath.js +96 -75
  79. package/xpath/xpath.js.map +1 -1
  80. package/xpathdebug.js +4 -4
  81. package/xslt/xslt.d.ts +32 -18
  82. package/xslt/xslt.js +230 -170
  83. package/xslt/xslt.js.map +1 -1
package/umd/dom/util.d.ts CHANGED
@@ -1,25 +1,6 @@
1
- export declare function assert(b: any): void;
2
- export declare function mapExec(array: any, func: any): void;
1
+ export declare function mapExec(array: any[], func: Function): void;
3
2
  export declare function mapExpr(array: any, func: any): any[];
4
- export declare function reverseInplace(array: any): void;
5
- export declare function copyArray(dst: any, src: any): void;
6
- /**
7
- * This is an optimization for copying attribute lists in IE. IE includes many
8
- * extraneous properties in its DOM attribute lists, which take require
9
- * significant extra processing when evaluating attribute steps. With this
10
- * function, we ignore any such attributes that has an empty string value.
11
- */
12
- export declare function copyArrayIgnoringAttributesWithoutValue(dst: any, src: any): void;
13
- export declare function regExpEscape(text: string): string;
14
- /**
15
- * Determines whether a predicate expression contains a "positional selector".
16
- * A positional selector filters nodes from the nodelist input based on their
17
- * position within that list. When such selectors are encountered, the
18
- * evaluation of the predicate cannot be depth-first, because the positional
19
- * selector may be based on the result of evaluating predicates that precede
20
- * it.
21
- */
22
- export declare function predicateExprHasPositionalSelector(expr: any, isRecursiveCall?: any): any;
3
+ export declare function reverseInPlace(array: any[]): void;
23
4
  export declare function namespaceMapAt(node: any): {
24
5
  xmlns: string;
25
6
  xml: string;
@@ -4,14 +4,14 @@ export declare class XDocument extends XNode {
4
4
  constructor();
5
5
  clear(): void;
6
6
  appendChild(node: any): void;
7
- createElement(name: any): any;
8
- createElementNS(namespace: any, name: any): any;
7
+ createElement(name: string): XNode;
8
+ createElementNS(namespace: any, name: any): XNode;
9
9
  createDocumentFragment(): XNode;
10
- createTextNode(value: any): any;
11
- createTransformedTextNode(value: any): any;
12
- createAttribute(name: any): any;
13
- createAttributeNS(namespace: any, name: any): any;
14
- createComment(data: any): any;
15
- createCDATASection(data: any): any;
16
- createDTDSection(data: any): any;
10
+ createTextNode(value: any): XNode;
11
+ createTransformedTextNode(value: any): XNode;
12
+ createAttribute(name: any): XNode;
13
+ createAttributeNS(namespace: any, name: any): XNode;
14
+ createComment(data: any): XNode;
15
+ createCDATASection(data: any): XNode;
16
+ createDTDSection(data: any): XNode;
17
17
  }
@@ -9,11 +9,13 @@ export declare class XNode {
9
9
  lastChild: XNode;
10
10
  nextSibling: XNode;
11
11
  previousSibling: XNode;
12
+ siblingPosition: number;
12
13
  ownerDocument: any;
13
- namespaceURI: any;
14
- prefix: any;
14
+ namespaceUri: any;
15
+ prefix: string;
15
16
  localName: string;
16
17
  parentNode: XNode;
18
+ outputNode: XNode;
17
19
  transformedAttributes: XNode[];
18
20
  transformedChildNodes: XNode[];
19
21
  transformedNodeType: any;
@@ -26,7 +28,7 @@ export declare class XNode {
26
28
  transformedPrefix: any;
27
29
  transformedLocalName: string;
28
30
  transformedParentNode: XNode;
29
- printed: boolean;
31
+ visited: boolean;
30
32
  escape: boolean;
31
33
  static _unusedXNodes: any[];
32
34
  constructor(type: any, name: any, opt_value: any, opt_owner: any, opt_namespace?: any);
@@ -41,7 +43,7 @@ export declare class XNode {
41
43
  init(type: any, name: string, value: string, owner: any, namespaceUri: any): void;
42
44
  protected qualifiedNameToParts(name: string): string[];
43
45
  static recycle(node: any): void;
44
- static create(type: any, name: any, value: any, owner: any, namespace?: any): any;
46
+ static create(type: any, name: any, value: any, owner: any, namespace?: any): XNode;
45
47
  static clone(node: XNode, newOwner: XNode): XNode;
46
48
  appendChild(node: XNode): void;
47
49
  appendTransformedChild(node: XNode): void;
@@ -61,4 +63,6 @@ export declare class XNode {
61
63
  getElementsByTagName(name: any): any[];
62
64
  getElementsByTagNameNS(namespace: any, localName: any): any[];
63
65
  getElementById(id: any): any;
66
+ getAncestorByLocalName(localName: string): XNode | undefined;
67
+ getAncestorById(id: number): XNode | undefined;
64
68
  }
@@ -0,0 +1,8 @@
1
+ export declare function copyArray(dst: any[], src: any[]): void;
2
+ /**
3
+ * This is an optimization for copying attribute lists in IE. IE includes many
4
+ * extraneous properties in its DOM attribute lists, which take require
5
+ * significant extra processing when evaluating attribute steps. With this
6
+ * function, we ignore any such attributes that has an empty string value.
7
+ */
8
+ export declare function copyArrayIgnoringAttributesWithoutValue(dst: any, src: any): void;
@@ -1,16 +1,89 @@
1
1
  import { XNode } from '../dom';
2
+ /** XPath expression evaluation context. An XPath context consists of a
3
+ * DOM node, a list of DOM nodes that contains this node, a number
4
+ * that represents the position of the single node in the list, and a
5
+ * current set of variable bindings. (See XPath spec.)
6
+ *
7
+ * setVariable(name, expr) -- binds given XPath expression to the
8
+ * name.
9
+ *
10
+ * getVariable(name) -- what the name says.
11
+ *
12
+ * setNode(position) -- sets the context to the node at the given
13
+ * position. Needed to implement scoping rules for variables in
14
+ * XPath. (A variable is visible to all subsequent siblings, not
15
+ * only to its children.)
16
+ *
17
+ * set/isCaseInsensitive -- specifies whether node name tests should
18
+ * be case sensitive. If you're executing xpaths against a regular
19
+ * HTML DOM, you probably don't want case-sensitivity, because
20
+ * browsers tend to disagree about whether elements & attributes
21
+ * should be upper/lower case. If you're running xpaths in an
22
+ * XSLT instance, you probably DO want case sensitivity, as per the
23
+ * XSL spec.
24
+ *
25
+ * set/isReturnOnFirstMatch -- whether XPath evaluation should quit as soon
26
+ * as a result is found. This is an optimization that might make sense if you
27
+ * only care about the first result.
28
+ *
29
+ * set/isIgnoreNonElementNodesForNTA -- whether to ignore non-element nodes
30
+ * when evaluating the "node()" any node test. While technically this is
31
+ * contrary to the XPath spec, practically it can enhance performance
32
+ * significantly, and makes sense if you a) use "node()" when you mean "*",
33
+ * and b) use "//" when you mean "/descendant::* /".
34
+ */
2
35
  export declare class ExprContext {
3
36
  position: number;
4
- nodelist: XNode[];
5
- variables: any;
6
- parent: any;
37
+ nodeList: XNode[];
38
+ outputPosition: number;
39
+ outputNodeList: XNode[];
40
+ outputDepth: number;
41
+ variables: {
42
+ [name: string]: any;
43
+ };
7
44
  caseInsensitive: any;
8
45
  ignoreAttributesWithoutValue: any;
9
46
  returnOnFirstMatch: any;
10
47
  ignoreNonElementNodesForNTA: any;
11
- root: any;
12
- constructor(nodelist: any[], opt_position?: number, opt_parent?: any, opt_caseInsensitive?: any, opt_ignoreAttributesWithoutValue?: any, opt_returnOnFirstMatch?: any, opt_ignoreNonElementNodesForNTA?: any);
13
- clone(opt_nodelist?: any[], opt_position?: any): ExprContext;
48
+ parent: ExprContext;
49
+ root: XNode;
50
+ inApplyTemplates: boolean;
51
+ baseTemplateMatched: boolean;
52
+ /**
53
+ * Constructor -- gets the node, its position, the node set it
54
+ * belongs to, and a parent context as arguments. The parent context
55
+ * is used to implement scoping rules for variables: if a variable
56
+ * is not found in the current context, it is looked for in the
57
+ * parent context, recursively. Except for node, all arguments have
58
+ * default values: default position is 0, default node set is the
59
+ * set that contains only the node, and the default parent is null.
60
+ *
61
+ * Notice that position starts at 0 at the outside interface;
62
+ * inside XPath expressions this shows up as position()=1.
63
+ * @param nodeList TODO
64
+ * @param outputNodeList TODO
65
+ * @param opt_position TODO
66
+ * @param opt_outputPosition TODO
67
+ * @param opt_parent TODO
68
+ * @param opt_caseInsensitive TODO
69
+ * @param opt_ignoreAttributesWithoutValue TODO
70
+ * @param opt_returnOnFirstMatch TODO
71
+ * @param opt_ignoreNonElementNodesForNTA TODO
72
+ */
73
+ constructor(nodeList: XNode[], outputNodeList: XNode[], opt_position?: number, opt_outputPosition?: number, opt_outputDepth?: number, opt_parent?: ExprContext, opt_caseInsensitive?: any, opt_ignoreAttributesWithoutValue?: any, opt_returnOnFirstMatch?: any, opt_ignoreNonElementNodesForNTA?: any);
74
+ /**
75
+ * clone() -- creates a new context with the current context as
76
+ * parent. If passed as argument to clone(), the new context has a
77
+ * different node, position, or node set. What is not passed is
78
+ * inherited from the cloned context.
79
+ * @param opt_nodeList TODO
80
+ * @param opt_outputNodeList TODO
81
+ * @param opt_position TODO
82
+ * @param opt_outputPosition TODO
83
+ * @returns TODO
84
+ */
85
+ clone(opt_nodeList?: XNode[], opt_outputNodeList?: XNode[], opt_position?: number, opt_outputPosition?: number): ExprContext;
86
+ cloneByOutput(opt_outputNodeList?: XNode[], opt_outputPosition?: number, opt_outputDepth?: number): ExprContext;
14
87
  setVariable(name?: any, value?: any): void;
15
88
  getVariable(name: string): any;
16
89
  setNode(position: number): void;
@@ -1,50 +1,12 @@
1
1
  import { ExprContext } from '../expr-context';
2
- import { BooleanValue } from '../values/boolean-value';
3
- import { NodeSetValue } from '../values/node-set-value';
4
- import { NumberValue } from '../values/number-value';
5
- import { StringValue } from '../values/string-value';
6
2
  import { Expression } from './expression';
7
3
  export declare class FunctionCallExpr extends Expression {
8
4
  name: any;
9
5
  args: any[];
10
- private cyrb53;
11
- xpathfunctions: {
12
- last(ctx: ExprContext): NumberValue;
13
- position(ctx: ExprContext): NumberValue;
14
- count(ctx: ExprContext): NumberValue;
15
- 'generate-id'(_ctx: ExprContext): StringValue;
16
- id(ctx: ExprContext): NodeSetValue;
17
- 'xml-to-json'(ctx: ExprContext): StringValue;
18
- 'local-name'(context: ExprContext): StringValue;
19
- 'namespace-uri'(ctx: ExprContext): StringValue;
20
- name(ctx: ExprContext): StringValue;
21
- string(ctx: ExprContext): StringValue;
22
- concat(ctx: ExprContext): StringValue;
23
- 'starts-with'(ctx: ExprContext): BooleanValue;
24
- 'ends-with'(ctx: ExprContext): BooleanValue;
25
- contains(ctx: ExprContext): BooleanValue;
26
- 'substring-before'(ctx: ExprContext): StringValue;
27
- 'substring-after'(ctx: ExprContext): StringValue;
28
- substring(ctx: ExprContext): StringValue;
29
- 'string-length'(ctx: ExprContext): NumberValue;
30
- 'normalize-space'(ctx: ExprContext): StringValue;
31
- translate(ctx: ExprContext): StringValue;
32
- matches(ctx: ExprContext): BooleanValue;
33
- boolean(ctx: ExprContext): BooleanValue;
34
- not(ctx: ExprContext): BooleanValue;
35
- true(): BooleanValue;
36
- false(): BooleanValue;
37
- lang(ctx: ExprContext): BooleanValue;
38
- number(ctx: ExprContext): NumberValue;
39
- sum(ctx: ExprContext): NumberValue;
40
- floor(ctx: ExprContext): NumberValue;
41
- ceiling(ctx: ExprContext): NumberValue;
42
- round(ctx: ExprContext): NumberValue;
43
- 'ext-join'(ctx: ExprContext): StringValue;
44
- 'ext-if'(ctx: ExprContext): any;
45
- 'ext-cardinal'(ctx: ExprContext): NodeSetValue;
6
+ xPathFunctions: {
7
+ [key: string]: Function;
46
8
  };
47
9
  constructor(name: any);
48
10
  appendArg(arg: any): void;
49
- evaluate(ctx: ExprContext): any;
11
+ evaluate(context: ExprContext): any;
50
12
  }
@@ -2,9 +2,10 @@ 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";
5
+ import { StepExpr } from "./step-expr";
5
6
  export declare class LocationExpr extends Expression {
6
7
  absolute: boolean;
7
- steps: any[];
8
+ steps: StepExpr[];
8
9
  xPath: XPath;
9
10
  constructor(xPath: XPath);
10
11
  appendStep(s: any): void;
@@ -1,14 +1,24 @@
1
- import { ExprContext } from "../expr-context";
2
- import { NodeSetValue } from "../values/node-set-value";
3
- import { Expression } from "./expression";
4
- import { XPath } from "../xpath";
1
+ import { ExprContext } from '../expr-context';
2
+ import { NodeSetValue } from '../values/node-set-value';
3
+ import { Expression } from './expression';
4
+ import { XPath } from '../xpath';
5
5
  export declare class StepExpr extends Expression {
6
6
  axis: any;
7
- nodetest: any;
7
+ nodeTest: any;
8
8
  predicate: any;
9
9
  hasPositionalPredicate: any;
10
10
  xPath: XPath;
11
- constructor(axis: any, nodetest: any, xPath: XPath, opt_predicate?: any);
11
+ constructor(axis: any, nodeTest: any, xPath: XPath, opt_predicate?: any);
12
+ /**
13
+ * Determines whether a predicate expression contains a "positional selector".
14
+ * A positional selector filters nodes from the nodeList input based on their
15
+ * position within that list. When such selectors are encountered, the
16
+ * evaluation of the predicate cannot be depth-first, because the positional
17
+ * selector may be based on the result of evaluating predicates that precede
18
+ * it.
19
+ */
20
+ private predicateExprHasPositionalSelector;
21
+ private exprReturnsNumberValue;
12
22
  appendPredicate(p: any): void;
13
23
  evaluate(context: ExprContext): NodeSetValue;
14
24
  }
@@ -2,8 +2,8 @@ import { ExprContext } from "..";
2
2
  import { NodeSetValue } from "../values/node-set-value";
3
3
  import { Expression } from "./expression";
4
4
  export declare class UnionExpr extends Expression {
5
- expr1: any;
6
- expr2: any;
7
- constructor(expr1: any, expr2: any);
8
- evaluate(ctx: ExprContext): NodeSetValue;
5
+ expr1: Expression;
6
+ expr2: Expression;
7
+ constructor(expr1: Expression, expr2: Expression);
8
+ evaluate(context: ExprContext): NodeSetValue;
9
9
  }
@@ -0,0 +1,2 @@
1
+ export * from './non-standard';
2
+ export * from './standard';
@@ -0,0 +1,2 @@
1
+ export declare function assert(b: any): void;
2
+ export declare function regExpEscape(text: string): string;
@@ -0,0 +1,12 @@
1
+ import { ExprContext } from "../expr-context";
2
+ import { NodeSetValue, StringValue } from "../values";
3
+ export declare function extCardinal(context: ExprContext): NodeSetValue;
4
+ /**
5
+ * evaluates and returns its second argument, if the
6
+ * boolean value of its first argument is true, otherwise it
7
+ * evaluates and returns its third argument.
8
+ * @param context The Expression Context
9
+ * @returns A `BooleanValue`.
10
+ */
11
+ export declare function extIf(context: ExprContext): any;
12
+ export declare function extJoin(context: ExprContext): StringValue;
@@ -0,0 +1,33 @@
1
+ import { ExprContext } from "../expr-context";
2
+ import { BooleanValue, NodeSetValue, NumberValue, StringValue } from "../values";
3
+ export declare function boolean(context: ExprContext): BooleanValue;
4
+ export declare function ceiling(context: ExprContext): NumberValue;
5
+ export declare function concat(context: ExprContext): StringValue;
6
+ export declare function contains(context: ExprContext): BooleanValue;
7
+ export declare function count(context: ExprContext): NumberValue;
8
+ export declare function endsWith(context: ExprContext): BooleanValue;
9
+ export declare function _false(): BooleanValue;
10
+ export declare function floor(context: ExprContext): NumberValue;
11
+ export declare function generateId(context: ExprContext): StringValue;
12
+ export declare function id(context: ExprContext): NodeSetValue;
13
+ export declare function lang(context: ExprContext): BooleanValue;
14
+ export declare function last(context: ExprContext): NumberValue;
15
+ export declare function localName(context: ExprContext): StringValue;
16
+ export declare function matches(context: ExprContext): BooleanValue;
17
+ export declare function _name(context: ExprContext): StringValue;
18
+ export declare function namespaceUri(context: ExprContext): StringValue;
19
+ export declare function normalizeSpace(context: ExprContext): StringValue;
20
+ export declare function not(context: ExprContext): BooleanValue;
21
+ export declare function number(context: ExprContext): NumberValue;
22
+ export declare function position(context: ExprContext): NumberValue;
23
+ export declare function round(context: ExprContext): NumberValue;
24
+ export declare function startsWith(context: ExprContext): BooleanValue;
25
+ export declare function _string(context: ExprContext): StringValue;
26
+ export declare function stringLength(context: ExprContext): NumberValue;
27
+ export declare function substring(context: ExprContext): StringValue;
28
+ export declare function substringAfter(context: ExprContext): StringValue;
29
+ export declare function substringBefore(context: ExprContext): StringValue;
30
+ export declare function sum(context: ExprContext): NumberValue;
31
+ export declare function translate(context: ExprContext): StringValue;
32
+ export declare function _true(): BooleanValue;
33
+ export declare function xmlToJson(context: ExprContext): StringValue;
@@ -1,4 +1,4 @@
1
- export declare const xpathAxis: {
1
+ export declare const xPathAxis: {
2
2
  ANCESTOR_OR_SELF: string;
3
3
  ANCESTOR: string;
4
4
  ATTRIBUTE: string;
@@ -12,6 +12,7 @@ export declare const xpathAxis: {
12
12
  PRECEDING_SIBLING: string;
13
13
  PRECEDING: string;
14
14
  SELF: string;
15
+ SELF_AND_SIBLINGS: string;
15
16
  };
16
17
  export declare const TOK_PIPE: {
17
18
  label: string;
@@ -1,5 +1,6 @@
1
1
  import { ExprContext } from './expr-context';
2
2
  import { BinaryExpr, FunctionCallExpr, LiteralExpr, LocationExpr, NumberExpr, PathExpr, PredicateExpr, StepExpr, TokenExpr, UnaryMinusExpr, UnionExpr, VariableExpr } from './expressions';
3
+ import { Expression } from './expressions/expression';
3
4
  import { NodeTestAny } from './node-test-any';
4
5
  import { NodeTestComment } from './node-test-comment';
5
6
  import { NodeTestElementOrAttribute } from './node-test-element-or-attribute';
@@ -19,6 +20,12 @@ export declare class XPath {
19
20
  }[] | ((rel: any, slash: any, step: any) => any))[] | (number | {
20
21
  label: string;
21
22
  key: any;
23
+ } | {
24
+ label: string;
25
+ key: any;
26
+ }[] | ((nodeTest: any, axis?: string) => StepExpr))[] | (number | {
27
+ label: string;
28
+ key: any;
22
29
  } | {
23
30
  label: string;
24
31
  }[] | ((name: any, pareno: any, arg1: any, args: any) => FunctionCallExpr))[] | (number | {
@@ -45,9 +52,9 @@ export declare class XPath {
45
52
  makeLocationExpr7(rel: any, dslash: any, step: any): any;
46
53
  makeStepExpr1(dot: any): StepExpr;
47
54
  makeStepExpr2(ddot: any): StepExpr;
48
- makeStepExpr3(axisname: any, axis: any, nodetest: any): StepExpr;
49
- makeStepExpr4(at: any, nodetest: any): StepExpr;
50
- makeStepExpr5(nodetest: any): StepExpr;
55
+ makeStepExpr3(axisname: any, axis: any, nodeTest: any): StepExpr;
56
+ makeStepExpr4(at: any, nodeTest: any): StepExpr;
57
+ makeStepExpr5(nodeTest: any, axis?: string): StepExpr;
51
58
  makeStepExpr6(step: any, predicate: any): any;
52
59
  makeAbbrevStep(abbrev: any): StepExpr;
53
60
  makeNodeTestExpr1(): NodeTestElementOrAttribute;
@@ -69,37 +76,45 @@ export declare class XPath {
69
76
  makeLiteralExpr(token: any): LiteralExpr;
70
77
  makeNumberExpr(token: any): NumberExpr;
71
78
  makeVariableReference(dollar: any, name: any): VariableExpr;
72
- makeSimpleExpr(expr: any): LocationExpr | NumberExpr | VariableExpr;
79
+ /**
80
+ * Used before parsing for optimization of common simple cases. See
81
+ * the begin of xPathParse() for which they are.
82
+ * @param expression The XPath expression.
83
+ * @param axis The axis, if required. Default is 'child'.
84
+ * @returns An `Expression` object.
85
+ */
86
+ makeSimpleExpr(expression: string, axis?: string): Expression;
73
87
  makeSimpleExpr2(expr: any): LocationExpr;
74
88
  stackToString(stack: any[]): string;
75
89
  xPathCacheLookup(expr: any): any;
76
- xPathCollectDescendants(nodelist: any, node: any, opt_tagName?: any): void;
77
- xPathCollectDescendantsReverse(nodelist: any, node: any): void;
90
+ xPathCollectDescendants(nodeList: any, node: any, opt_tagName?: any): void;
91
+ xPathCollectDescendantsReverse(nodeList: any, node: any): void;
78
92
  xPathEval(select: string, context: ExprContext): any;
79
93
  /**
80
94
  * DGF - extract a tag name suitable for getElementsByTagName
81
95
  *
82
- * @param nodetest the node test
96
+ * @param nodeTest the node test
83
97
  * @param ignoreNonElementNodesForNTA if true, the node list returned when
84
98
  * evaluating "node()" will not contain
85
99
  * non-element nodes. This can boost
86
100
  * performance. This is false by default.
87
101
  */
88
- xPathExtractTagNameFromNodeTest(nodetest: any, ignoreNonElementNodesForNTA: any): string;
102
+ xPathExtractTagNameFromNodeTest(nodeTest: any, ignoreNonElementNodesForNTA: any): string;
89
103
  xPathMatchStack(stack: any, pattern: any): any;
90
104
  /**
91
105
  * The entry point for the parser.
92
- * @param expr a string that contains an XPath expression.
106
+ * @param expression a string that contains an XPath expression.
107
+ * @param axis The XPath axis. Used when the match does not start with the parent.
93
108
  * @param xPathLog TODO
94
109
  * @returns an expression object that can be evaluated with an
95
110
  * expression context.
96
111
  */
97
- xPathParse(expr: any, xPathLog?: (message: string) => void): any;
112
+ xPathParse(expression: string, axis?: string, xPathLog?: (message: string) => void): any;
98
113
  xPathParseInit(xPathLog: Function): void;
99
- xPathReduce(stack: any, ahead: any, xpathLog?: (message: string) => void): any;
114
+ xPathReduce(stack: any, ahead: any, axis?: string, xpathLog?: (message: string) => void): any;
100
115
  xPathSort(context: ExprContext, sort: any[]): void;
101
116
  xPathSortByKey(v1: any, v2: any): number;
102
- xPathStep(nodes: any[], steps: any[], step: any, input: any, ctx: ExprContext): void;
117
+ xPathStep(nodes: any[], steps: any[], step: any, input: any, context: ExprContext): void;
103
118
  xPathGrammarPrecedence(frame: any): number;
104
119
  xPathTokenPrecedence(tag: any): any;
105
120
  }
@@ -1,7 +1,6 @@
1
1
  import { XDocument, XNode } from '../dom';
2
2
  import { ExprContext, XPath } from '../xpath';
3
3
  import { XsltOptions } from './xslt-options';
4
- import { XsltParameter } from './xslt-parameter';
5
4
  /**
6
5
  * The main class for XSL-T processing. The implementation is NOT
7
6
  * complete; some xsl element are left out.
@@ -29,25 +28,24 @@ import { XsltParameter } from './xslt-parameter';
29
28
  export declare class Xslt {
30
29
  xPath: XPath;
31
30
  options: XsltOptions;
31
+ outputDocument: XDocument;
32
32
  outputMethod: string;
33
33
  outputOmitXmlDeclaration: string;
34
- constructor(options?: XsltOptions);
34
+ constructor(options?: Partial<XsltOptions>);
35
35
  /**
36
36
  * The exported entry point of the XSL-T processor.
37
37
  * @param xmlDoc The input document root, as DOM node.
38
38
  * @param stylesheet The stylesheet document root, as DOM node.
39
- * @param parameters Additional parameters to be set as variables.
40
39
  * @returns the processed document, as XML text in a string.
41
40
  */
42
- xsltProcess(xmlDoc: XDocument, stylesheet: XDocument, parameters?: XsltParameter[]): string;
41
+ xsltProcess(xmlDoc: XDocument, stylesheet: XDocument): string;
43
42
  /**
44
43
  * The main entry point of the XSL-T processor, as explained on the top of the file.
45
44
  * @param context The input document root, as XPath ExprContext.
46
45
  * @param template The stylesheet document root, as DOM node.
47
46
  * @param output the root of the generated output, as DOM node.
48
- * @param _parameters Extra parameters.
49
47
  */
50
- protected xsltProcessContext(context: ExprContext, template: XNode, output: XNode, _parameters: XsltParameter[]): void;
48
+ protected xsltProcessContext(context: ExprContext, template: XNode, output: XNode): void;
51
49
  /**
52
50
  * Implements `xsl:copy` for all node types.
53
51
  * @param {XNode} destination the node being copied to, part of output document
@@ -77,7 +75,7 @@ export declare class Xslt {
77
75
  * case. I.e. decides if this is a default value or a local
78
76
  * value. `xsl:variable` and `xsl:with-param` override; `xsl:param` doesn't.
79
77
  */
80
- protected xsltVariable(input: ExprContext, template: any, override: boolean, _parameters: XsltParameter[]): void;
78
+ protected xsltVariable(input: ExprContext, template: any, override: boolean): void;
81
79
  /**
82
80
  * Implements xsl:choose and its child nodes xsl:when and
83
81
  * xsl:otherwise.
@@ -85,14 +83,14 @@ export declare class Xslt {
85
83
  * @param template The template.
86
84
  * @param output The output.
87
85
  */
88
- protected xsltChoose(input: ExprContext, template: any, output: any, _parameters: XsltParameter[]): void;
86
+ protected xsltChoose(input: ExprContext, template: any, output: any): void;
89
87
  /**
90
88
  * Implements `xsl:for-each`.
91
89
  * @param input The Expression Context.
92
90
  * @param template The template.
93
91
  * @param output The output.
94
92
  */
95
- protected xsltForEach(context: ExprContext, template: XNode, output: XNode, _parameters: XsltParameter[]): void;
93
+ protected xsltForEach(context: ExprContext, template: XNode, output: XNode): void;
96
94
  protected groupBy(xs: any, key: any): any;
97
95
  /**
98
96
  * Traverses the template node tree. Calls the main processing
@@ -102,7 +100,7 @@ export declare class Xslt {
102
100
  * @param template The XSL-T definition.
103
101
  * @param output The XML output.
104
102
  */
105
- protected xsltChildNodes(context: ExprContext, template: any, output: XNode, _parameters: XsltParameter[]): void;
103
+ protected xsltChildNodes(context: ExprContext, template: XNode, output: XNode): void;
106
104
  /**
107
105
  * Passes template text to the output. The current template node does
108
106
  * not specify an XSL-T operation and therefore is appended to the
@@ -111,9 +109,8 @@ export declare class Xslt {
111
109
  * @param context The Expression Context.
112
110
  * @param template The XSLT stylesheet or transformation.
113
111
  * @param output The output.
114
- * @param outputDocument The output document, if the case.
115
112
  */
116
- protected xsltPassThrough(context: ExprContext, template: any, output: XNode, outputDocument: XDocument, _parameters?: XsltParameter[]): void;
113
+ protected xsltPassThrough(context: ExprContext, template: XNode, output: XNode): void;
117
114
  /**
118
115
  * Determines if a text node in the XSLT template document is to be
119
116
  * stripped according to XSLT whitespace stripping rules.
@@ -148,11 +145,30 @@ export declare class Xslt {
148
145
  * match.
149
146
  * @see [XSLT] section 5.2, paragraph 1
150
147
  * @param match TODO
151
- * @param context TODO
152
- * @returns TODO
148
+ * @param context The Expression Context.
149
+ * @param axis The XPath axis. Used when the match does not start with the parent.
150
+ * @returns {XNode[]} A list of the found nodes.
153
151
  */
154
- protected xsltMatch(match: string, context: ExprContext): any;
152
+ protected xsltMatch(match: string, context: ExprContext, axis?: string): XNode[];
155
153
  private xsltLocationExpressionMatch;
154
+ /**
155
+ * Finds all the nodes through absolute xPath search.
156
+ * Returns only nodes that match either the context position node,
157
+ * or an ancestor.
158
+ * @param expression The Expression.
159
+ * @param context The Expression Context.
160
+ * @returns The list of found nodes.
161
+ */
162
+ private absoluteXsltMatch;
163
+ /**
164
+ * Tries to find relative nodes from the actual context position.
165
+ * If found nodes are already in the context, or if they are children of
166
+ * nodes in the context, they are returned.
167
+ * @param expression The expression used.
168
+ * @param context The Expression Context.
169
+ * @returns The list of found nodes.
170
+ */
171
+ private relativeXsltMatch;
156
172
  /**
157
173
  * Sets parameters defined by xsl:with-param child nodes of the
158
174
  * current template node, in the current input context. This happens
@@ -161,8 +177,6 @@ export declare class Xslt {
161
177
  * @param input TODO
162
178
  * @param template TODO
163
179
  */
164
- protected xsltWithParam(input: ExprContext, template: any, _parameters: XsltParameter[]): void;
165
- private absoluteXsltMatch;
166
- private relativeXsltMatch;
180
+ protected xsltWithParam(input: ExprContext, template: any): void;
167
181
  protected isXsltElement(element: any, opt_wantedName?: string): boolean;
168
182
  }