xslt-processor 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -96,10 +96,10 @@ const xslt = new Xslt(options);
96
96
  You can simply add a tag like this:
97
97
 
98
98
  ```html
99
- <script type="application/javascript" src="https://www.unpkg.com/xslt-processor@2.1.0/umd/xslt-processor.js"></script>
99
+ <script type="application/javascript" src="https://www.unpkg.com/xslt-processor@3.0.0/umd/xslt-processor.js"></script>
100
100
  ```
101
101
 
102
- All the exports will live under `globalThis.XsltProcessor`. [See a usage example here](https://github.com/DesignLiquido/xslt-processor/blob/main/interactive-tests/xslt.html).
102
+ All the exports will live under `globalThis.XsltProcessor` and `window.XsltProcessor`. [See a usage example here](https://github.com/DesignLiquido/xslt-processor/blob/main/interactive-tests/xslt.html).
103
103
 
104
104
  ### Breaking Changes
105
105
 
package/dom/util.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export declare function mapExec(array: any[], func: Function): void;
2
- export declare function mapExpr(array: any, func: any): any[];
2
+ export declare function mapExpr(array: any[], func: Function): any[];
3
3
  /**
4
4
  * Reverses the given array in place.
5
5
  * @param array The array to be reversed.
package/dom/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/dom/util.ts"],"names":[],"mappings":";AAAA,qCAAqC;AACrC,+BAA+B;AAC/B,wBAAwB;AACxB,EAAE;AACF,uDAAuD;AACvD,EAAE;AACF,mDAAmD;AACnD,sEAAsE;AACtE,iCAAiC;;;AAEjC,sEAAsE;AACtE,+BAA+B;AAC/B,SAAgB,OAAO,CAAC,KAAY,EAAE,IAAc;IAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,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CAAC,EAAE,CAAC,CAAC,CAAC;KAChC;AACL,CAAC;AAJD,0BAIC;AAED,+DAA+D;AAC/D,wDAAwD;AACxD,SAAgB,OAAO,CAAC,KAAY,EAAE,IAAc;IAChD,IAAM,GAAG,GAAG,EAAE,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5B;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAND,0BAMC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAY;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;QACvC,IAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,IAAM,EAAE,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;QAChC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;QACrB,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;KACjB;AACL,CAAC;AAPD,wCAOC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xslt-processor",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "A JavaScript XSLT Processor",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -47,16 +47,16 @@
47
47
  "@rollup/plugin-terser": "^0.4.3",
48
48
  "@rollup/plugin-typescript": "^11.1.1",
49
49
  "@types/he": "^1.2.0",
50
- "@types/jest": "^29.5.2",
50
+ "@types/jest": "^29.5.12",
51
51
  "@typescript-eslint/eslint-plugin": "^5.60.0",
52
52
  "@typescript-eslint/parser": "^5.60.0",
53
- "babel-jest": "^29.5.0",
53
+ "babel-jest": "^29.7.0",
54
54
  "copy-files-from-to": "^3.9.0",
55
55
  "copyfiles": "^2.4.1",
56
56
  "eslint": "^5.12.1",
57
57
  "eslint-plugin-jest": "^27.2.2",
58
58
  "eslint-plugin-jsx": "^0.1.0",
59
- "jest": "^29.5.0",
59
+ "jest": "^29.7.0",
60
60
  "npm-check-updates": "^16.10.13",
61
61
  "release-it": "^15.11.0",
62
62
  "rimraf": "^5.0.1",
@@ -65,9 +65,9 @@
65
65
  "rollup-plugin-commonjs": "^9.2.0",
66
66
  "rollup-plugin-node-resolve": "^4.0.0",
67
67
  "rollup-plugin-terser": "^4.0.3",
68
- "ts-jest": "^29.1.0",
69
- "ts-node": "^10.9.1",
70
- "typescript": "4.9.4"
68
+ "ts-jest": "^29.1.5",
69
+ "ts-node": "^10.9.2",
70
+ "typescript": "^4.9.5"
71
71
  },
72
72
  "dependencies": {
73
73
  "he": "^1.2.0",
package/umd/dom/util.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export declare function mapExec(array: any[], func: Function): void;
2
- export declare function mapExpr(array: any, func: any): any[];
2
+ export declare function mapExpr(array: any[], func: Function): any[];
3
3
  /**
4
4
  * Reverses the given array in place.
5
5
  * @param array The array to be reversed.
@@ -4,5 +4,5 @@ import { NodeTest } from "./node-test";
4
4
  export declare class NodeTestPI implements NodeTest {
5
5
  target: any;
6
6
  constructor(target: any);
7
- evaluate(ctx: ExprContext): BooleanValue;
7
+ evaluate(context: ExprContext): BooleanValue;
8
8
  }
@@ -50,13 +50,13 @@ export declare const TOK_NUMBER: XPathTokenRule;
50
50
  export declare const TOK_QNAME: XPathTokenRule;
51
51
  export declare const TOK_NODEO: XPathTokenRule;
52
52
  export declare const xPathTokenRules: XPathTokenRule[];
53
- export declare const Q_01: {
53
+ export declare const Q_ZERO_OR_ONE: {
54
54
  label: string;
55
55
  };
56
- export declare const Q_MM: {
56
+ export declare const Q_ZERO_OR_MULTIPLE: {
57
57
  label: string;
58
58
  };
59
- export declare const Q_1M: {
59
+ export declare const Q_ONE_OR_MULTIPLE: {
60
60
  label: string;
61
61
  };
62
62
  export declare const ASSOC_LEFT = true;
@@ -60,15 +60,15 @@ export declare class XPath {
60
60
  makeAbbrevStep(abbrev: any): StepExpr;
61
61
  makeNodeTestExpr1(): NodeTestElementOrAttribute;
62
62
  makeNodeTestExpr2(ncname: any): NodeTestNC;
63
- makeNodeTestExpr3(qname: any): NodeTestName;
63
+ makeNodeTestExpr3(qname: TokenExpr): NodeTestName;
64
64
  makeNodeTestExpr4(typeo: any): NodeTestAny | NodeTestComment | NodeTestPI | NodeTestText;
65
65
  makeNodeTestExpr5(typeo: any, target: any): NodeTestPI;
66
- makePredicateExpr(pareno: any, expr: any): PredicateExpr;
67
- makePrimaryExpr(pareno: any, expr: any): any;
66
+ makePredicateExpr(pareno: any, expression: any): PredicateExpr;
67
+ makePrimaryExpr(pareno: any, expression: any): any;
68
68
  makeFunctionCallExpr1(name: any): FunctionCallExpr;
69
69
  makeFunctionCallExpr2(name: any, pareno: any, arg1: any, args: any): FunctionCallExpr;
70
- makeArgumentExpr(comma: any, expr: any): any;
71
- makeUnionExpr(expr1: any, pipe: any, expr2: any): UnionExpr;
70
+ makeArgumentExpr(comma: any, expression: any): any;
71
+ makeUnionExpr(expr1: Expression, pipe: TokenExpr, expr2: Expression): UnionExpr;
72
72
  makePathExpr1(filter: any, slash: any, rel: any): PathExpr;
73
73
  makePathExpr2(filter: any, dslash: any, rel: any): PathExpr;
74
74
  makeFilterExpr(expr: any, predicates: any): any;
@@ -108,7 +108,7 @@ export declare class XPath {
108
108
  * performance. This is false by default.
109
109
  */
110
110
  xPathExtractTagNameFromNodeTest(nodeTest: NodeTest, ignoreNonElementNodesForNTA: any): string;
111
- xPathMatchStack(stack: any, pattern: any): any;
111
+ xPathMatchStack(stack: any[], pattern: any[]): any;
112
112
  /**
113
113
  * Finds the best rule for the XPath expression provided.
114
114
  * @param expression The XPath string expression.
@@ -139,8 +139,8 @@ export declare class XPath {
139
139
  * grammatical rules to them, "reducing" them to higher-level
140
140
  * tokens. Ultimately, any valid XPath should reduce to exactly one
141
141
  * "Expr" token.
142
-
143
- * Reduce too early or too late and you'll have two tokens that can't reduce
142
+ *
143
+ * Reduce too early or too late, and you'll have two tokens that can't reduce
144
144
  * to single Expr. For example, you may hastily reduce a qname that
145
145
  * should name a function, incorrectly treating it as a tag name.
146
146
  * Or you may reduce too late, accidentally reducing the last part of the
@@ -155,6 +155,10 @@ export declare class XPath {
155
155
  *
156
156
  * Some tokens have left associativity, in which case we shift when they
157
157
  * have LOWER precedence than the candidate.
158
+ * @param stack The actual grammar rule stack.
159
+ * @param ahead The grammar rule ahead.
160
+ * @return `true` if a grammar rule candidate was applied. `false` otherwise.
161
+ * @private
158
162
  */
159
163
  private xPathReduce;
160
164
  /**
@@ -52,6 +52,22 @@ export declare class Xslt {
52
52
  * @param output If set, the output where the transformation should occur.
53
53
  */
54
54
  protected xsltProcessContext(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
55
+ /**
56
+ * Implements `xsl:apply-templates`.
57
+ * @param context The Expression Context.
58
+ * @param template The template.
59
+ * @param output The output. Only used if there's no corresponding output node already defined.
60
+ * @protected
61
+ */
62
+ protected xsltApplyTemplates(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
63
+ /**
64
+ * Implements `xsl:attribute`.
65
+ * @param context The Expression Context.
66
+ * @param template The template.
67
+ * @param output The output. Only used if there's no corresponding output node already defined.
68
+ * @protected
69
+ */
70
+ protected xsltAttribute(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
55
71
  /**
56
72
  * Implements `xsl:choose`, its child nodes `xsl:when`, and
57
73
  * `xsl:otherwise`.
@@ -77,14 +93,14 @@ export declare class Xslt {
77
93
  protected xsltCopyOf(destination: XNode, source: XNode): void;
78
94
  /**
79
95
  * Implements `xsl:for-each`.
80
- * @param input The Expression Context.
96
+ * @param context The Expression Context.
81
97
  * @param template The template.
82
98
  * @param output The output.
83
99
  */
84
100
  protected xsltForEach(context: ExprContext, template: XNode, output: XNode): Promise<void>;
85
101
  /**
86
102
  * Implements `xsl:include`.
87
- * @param input The Expression Context.
103
+ * @param context The Expression Context.
88
104
  * @param template The template.
89
105
  * @param output The output.
90
106
  */
@@ -134,6 +150,7 @@ export declare class Xslt {
134
150
  * - `xsltProcessContext`, `apply-templates` operation, when the current node is text.
135
151
  * @param context The Expression Context.
136
152
  * @param template The template, that contains the node value to be written.
153
+ * @param output The output.
137
154
  */
138
155
  private commonLogicTextNode;
139
156
  /**
@@ -156,7 +173,7 @@ export declare class Xslt {
156
173
  * currently not implemented.
157
174
  */
158
175
  protected xsltPassText(template: XNode): boolean;
159
- protected xsltAttribute(attributeName: string, context: ExprContext): XNode;
176
+ protected findAttributeInContext(attributeName: string, context: ExprContext): XNode;
160
177
  /**
161
178
  * Evaluates an XSL-T attribute value template. Attribute value
162
179
  * templates are attributes on XSL-T elements that contain XPath