xslt-processor 5.0.0 → 5.0.2
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 +41 -1
- package/index.d.mts +18 -17
- package/index.d.ts +18 -17
- package/index.js +58 -34
- package/index.js.map +1 -1
- package/index.mjs +58 -34
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/umd/xslt-processor.global.js +2 -2
- package/umd/xslt-processor.global.js.map +1 -1
package/index.mjs
CHANGED
|
@@ -6450,8 +6450,15 @@ var init_function_call_expression = __esm({
|
|
|
6450
6450
|
return !!value;
|
|
6451
6451
|
}
|
|
6452
6452
|
toNumber(args, context) {
|
|
6453
|
+
const toNumberFromString = (text) => {
|
|
6454
|
+
const trimmed = text.trim();
|
|
6455
|
+
if (trimmed.length === 0) {
|
|
6456
|
+
return NaN;
|
|
6457
|
+
}
|
|
6458
|
+
return Number(trimmed);
|
|
6459
|
+
};
|
|
6453
6460
|
if (args.length === 0) {
|
|
6454
|
-
return
|
|
6461
|
+
return toNumberFromString(this.stringValue([], context));
|
|
6455
6462
|
}
|
|
6456
6463
|
const value = args[0];
|
|
6457
6464
|
if (typeof value === "object" && value !== null && "numberValue" in value && typeof value.numberValue === "function") {
|
|
@@ -6461,7 +6468,10 @@ var init_function_call_expression = __esm({
|
|
|
6461
6468
|
if (value.length === 0) return NaN;
|
|
6462
6469
|
const firstNode = value[0];
|
|
6463
6470
|
const stringValue = this.getNodeStringValue(firstNode);
|
|
6464
|
-
return
|
|
6471
|
+
return toNumberFromString(stringValue);
|
|
6472
|
+
}
|
|
6473
|
+
if (typeof value === "string") {
|
|
6474
|
+
return toNumberFromString(value);
|
|
6465
6475
|
}
|
|
6466
6476
|
return Number(value);
|
|
6467
6477
|
}
|
|
@@ -11619,7 +11629,11 @@ var StringValue = class {
|
|
|
11619
11629
|
return this.value.length > 0;
|
|
11620
11630
|
}
|
|
11621
11631
|
numberValue() {
|
|
11622
|
-
|
|
11632
|
+
const text = String(this.value).trim();
|
|
11633
|
+
if (text.length === 0) {
|
|
11634
|
+
return NaN;
|
|
11635
|
+
}
|
|
11636
|
+
return Number(text);
|
|
11623
11637
|
}
|
|
11624
11638
|
nodeSetValue() {
|
|
11625
11639
|
throw this;
|
|
@@ -11853,28 +11867,37 @@ var NodeConverter = class {
|
|
|
11853
11867
|
*/
|
|
11854
11868
|
convertVariables(exprContext) {
|
|
11855
11869
|
const variables = {};
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
|
|
11870
|
+
const contexts = [];
|
|
11871
|
+
let ctx = exprContext;
|
|
11872
|
+
while (ctx) {
|
|
11873
|
+
contexts.push(ctx);
|
|
11874
|
+
ctx = ctx.parent;
|
|
11875
|
+
}
|
|
11876
|
+
for (let i = contexts.length - 1; i >= 0; i--) {
|
|
11877
|
+
const current = contexts[i];
|
|
11878
|
+
for (const [name, value] of Object.entries(current.variables || {})) {
|
|
11879
|
+
if (value && typeof value === "object" && "stringValue" in value) {
|
|
11880
|
+
const nodeValue = value;
|
|
11881
|
+
if (nodeValue.type === "node-set") {
|
|
11882
|
+
variables[name] = value.nodeSetValue().map((n) => this.adaptXNode(n));
|
|
11883
|
+
} else if (nodeValue.type === "string") {
|
|
11884
|
+
variables[name] = value.stringValue();
|
|
11885
|
+
} else if (nodeValue.type === "number") {
|
|
11886
|
+
variables[name] = value.numberValue();
|
|
11887
|
+
} else if (nodeValue.type === "boolean") {
|
|
11888
|
+
variables[name] = value.booleanValue();
|
|
11889
|
+
} else if (nodeValue.type === "map") {
|
|
11890
|
+
variables[name] = nodeValue.value;
|
|
11891
|
+
} else if (nodeValue.type === "array") {
|
|
11892
|
+
variables[name] = nodeValue.value;
|
|
11893
|
+
} else if (nodeValue.type === "function") {
|
|
11894
|
+
variables[name] = nodeValue.value;
|
|
11895
|
+
} else {
|
|
11896
|
+
variables[name] = value.stringValue();
|
|
11897
|
+
}
|
|
11873
11898
|
} else {
|
|
11874
|
-
variables[name] = value
|
|
11899
|
+
variables[name] = value;
|
|
11875
11900
|
}
|
|
11876
|
-
} else {
|
|
11877
|
-
variables[name] = value;
|
|
11878
11901
|
}
|
|
11879
11902
|
}
|
|
11880
11903
|
return variables;
|
|
@@ -12409,13 +12432,14 @@ var ExprContext = class _ExprContext {
|
|
|
12409
12432
|
*
|
|
12410
12433
|
* Notice that position starts at 0 at the outside interface;
|
|
12411
12434
|
* inside XPath expressions this shows up as position()=1.
|
|
12412
|
-
* @param nodeList
|
|
12413
|
-
* @param
|
|
12414
|
-
* @param
|
|
12415
|
-
* @param
|
|
12416
|
-
* @param
|
|
12417
|
-
* @param
|
|
12418
|
-
* @param
|
|
12435
|
+
* @param nodeList The list of nodes that contains the current node. This is needed to implement the position() and last() functions, and to evaluate predicates.
|
|
12436
|
+
* @param xsltVersion The XSLT version in use, which may affect certain function behaviors (e.g. 1.0 vs 2.0).
|
|
12437
|
+
* @param opt_position The position of the current node in the nodeList. Defaults to 0.
|
|
12438
|
+
* @param opt_parent The parent expression context, used for variable scoping. Defaults to null.
|
|
12439
|
+
* @param opt_caseInsensitive Whether node name tests should be case insensitive. Defaults to false.
|
|
12440
|
+
* @param opt_ignoreAttributesWithoutValue Whether to ignore attributes that have no value (e.g. <input disabled>) when evaluating XPath expressions. Defaults to false.
|
|
12441
|
+
* @param opt_returnOnFirstMatch Whether XPath evaluation should return as soon as the first match is found. Defaults to false.
|
|
12442
|
+
* @param opt_ignoreNonElementNodesForNTA Whether to ignore non-element nodes when evaluating the "node()" any node test. Defaults to false.
|
|
12419
12443
|
*/
|
|
12420
12444
|
constructor(nodeList, xsltVersion = "1.0", opt_position, opt_decimalFormatSettings, opt_variables, opt_knownNamespaces, opt_parent, opt_caseInsensitive, opt_ignoreAttributesWithoutValue, opt_returnOnFirstMatch, opt_ignoreNonElementNodesForNTA, opt_warningsCallback) {
|
|
12421
12445
|
this.nodeList = nodeList;
|
|
@@ -12457,9 +12481,9 @@ var ExprContext = class _ExprContext {
|
|
|
12457
12481
|
* parent. If passed as argument to clone(), the new context has a
|
|
12458
12482
|
* different node, position, or node set. What is not passed is
|
|
12459
12483
|
* inherited from the cloned context.
|
|
12460
|
-
* @param opt_nodeList
|
|
12461
|
-
* @param opt_position
|
|
12462
|
-
* @returns
|
|
12484
|
+
* @param opt_nodeList The node list for the new context. If not provided, the new context inherits the node list of the current context.
|
|
12485
|
+
* @param opt_position The position for the new context. If not provided, the new context inherits the position of the current context.
|
|
12486
|
+
* @returns A new ExprContext instance with the specified node list and position, and the current context as its parent.
|
|
12463
12487
|
*/
|
|
12464
12488
|
clone(opt_nodeList, opt_position) {
|
|
12465
12489
|
return new _ExprContext(
|
|
@@ -12467,7 +12491,7 @@ var ExprContext = class _ExprContext {
|
|
|
12467
12491
|
this.xsltVersion,
|
|
12468
12492
|
typeof opt_position !== "undefined" ? opt_position : this.position,
|
|
12469
12493
|
this.decimalFormatSettings,
|
|
12470
|
-
this.variables,
|
|
12494
|
+
Object.create(this.variables || {}),
|
|
12471
12495
|
this.knownNamespaces,
|
|
12472
12496
|
this,
|
|
12473
12497
|
this.caseInsensitive,
|