xslt-processor 1.1.5 → 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 (90) hide show
  1. package/README.md +3 -1
  2. package/dom/functions.d.ts +11 -5
  3. package/dom/functions.js +11 -6
  4. package/dom/functions.js.map +1 -1
  5. package/dom/util.d.ts +2 -21
  6. package/dom/util.js +3 -111
  7. package/dom/util.js.map +1 -1
  8. package/dom/xdocument.d.ts +9 -9
  9. package/dom/xdocument.js.map +1 -1
  10. package/dom/xml-functions.d.ts +3 -3
  11. package/dom/xml-functions.js +41 -25
  12. package/dom/xml-functions.js.map +1 -1
  13. package/dom/xml-output-options.d.ts +1 -0
  14. package/dom/xnode.d.ts +8 -4
  15. package/dom/xnode.js +30 -11
  16. package/dom/xnode.js.map +1 -1
  17. package/package.json +1 -1
  18. package/umd/dom/functions.d.ts +11 -5
  19. package/umd/dom/util.d.ts +2 -21
  20. package/umd/dom/xdocument.d.ts +9 -9
  21. package/umd/dom/xml-functions.d.ts +3 -3
  22. package/umd/dom/xml-output-options.d.ts +1 -0
  23. package/umd/dom/xnode.d.ts +8 -4
  24. package/umd/xpath/common-function.d.ts +8 -0
  25. package/umd/xpath/expr-context.d.ts +79 -6
  26. package/umd/xpath/expressions/function-call-expr.d.ts +3 -41
  27. package/umd/xpath/expressions/location-expr.d.ts +2 -1
  28. package/umd/xpath/expressions/step-expr.d.ts +16 -6
  29. package/umd/xpath/expressions/union-expr.d.ts +4 -4
  30. package/umd/xpath/functions/index.d.ts +2 -0
  31. package/umd/xpath/functions/internal-functions.d.ts +2 -0
  32. package/umd/xpath/functions/non-standard.d.ts +12 -0
  33. package/umd/xpath/functions/standard.d.ts +33 -0
  34. package/umd/xpath/tokens.d.ts +2 -1
  35. package/umd/xpath/xpath.d.ts +27 -12
  36. package/umd/xslt/xslt-options.d.ts +1 -0
  37. package/umd/xslt/xslt.d.ts +32 -18
  38. package/umd/xslt-processor.js +2 -2
  39. package/umd/xslt-processor.js.map +1 -1
  40. package/xpath/common-function.d.ts +8 -0
  41. package/xpath/common-function.js +33 -0
  42. package/xpath/common-function.js.map +1 -0
  43. package/xpath/expr-context.d.ts +79 -6
  44. package/xpath/expr-context.js +82 -59
  45. package/xpath/expr-context.js.map +1 -1
  46. package/xpath/expressions/filter-expr.js +1 -1
  47. package/xpath/expressions/filter-expr.js.map +1 -1
  48. package/xpath/expressions/function-call-expr.d.ts +3 -41
  49. package/xpath/expressions/function-call-expr.js +42 -346
  50. package/xpath/expressions/function-call-expr.js.map +1 -1
  51. package/xpath/expressions/location-expr.d.ts +2 -1
  52. package/xpath/expressions/location-expr.js +9 -9
  53. package/xpath/expressions/location-expr.js.map +1 -1
  54. package/xpath/expressions/path-expr.js +2 -2
  55. package/xpath/expressions/path-expr.js.map +1 -1
  56. package/xpath/expressions/step-expr.d.ts +16 -6
  57. package/xpath/expressions/step-expr.js +184 -113
  58. package/xpath/expressions/step-expr.js.map +1 -1
  59. package/xpath/expressions/union-expr.d.ts +4 -4
  60. package/xpath/expressions/union-expr.js +3 -3
  61. package/xpath/expressions/union-expr.js.map +1 -1
  62. package/xpath/functions/index.d.ts +2 -0
  63. package/xpath/functions/index.js +19 -0
  64. package/xpath/functions/index.js.map +1 -0
  65. package/xpath/functions/internal-functions.d.ts +2 -0
  66. package/xpath/functions/internal-functions.js +23 -0
  67. package/xpath/functions/internal-functions.js.map +1 -0
  68. package/xpath/functions/non-standard.d.ts +12 -0
  69. package/xpath/functions/non-standard.js +46 -0
  70. package/xpath/functions/non-standard.js.map +1 -0
  71. package/xpath/functions/standard.d.ts +33 -0
  72. package/xpath/functions/standard.js +345 -0
  73. package/xpath/functions/standard.js.map +1 -0
  74. package/xpath/node-test-element-or-attribute.js +1 -1
  75. package/xpath/node-test-name.js +1 -1
  76. package/xpath/tokens.d.ts +2 -1
  77. package/xpath/tokens.js +19 -17
  78. package/xpath/tokens.js.map +1 -1
  79. package/xpath/values/index.js +32 -0
  80. package/xpath/values/index.js.map +1 -1
  81. package/xpath/values/string-value.js +0 -32
  82. package/xpath/values/string-value.js.map +1 -1
  83. package/xpath/xpath.d.ts +27 -12
  84. package/xpath/xpath.js +96 -75
  85. package/xpath/xpath.js.map +1 -1
  86. package/xpathdebug.js +4 -4
  87. package/xslt/xslt-options.d.ts +1 -0
  88. package/xslt/xslt.d.ts +32 -18
  89. package/xslt/xslt.js +232 -171
  90. package/xslt/xslt.js.map +1 -1
@@ -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,5 +1,6 @@
1
1
  import { XsltParameter } from "./xslt-parameter";
2
2
  export type XsltOptions = {
3
3
  escape: boolean;
4
+ selfClosingTags: boolean;
4
5
  parameters?: XsltParameter[];
5
6
  };
@@ -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
  }