xslt-processor 5.0.1 → 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/index.d.mts CHANGED
@@ -308,13 +308,14 @@ declare class ExprContext {
308
308
  *
309
309
  * Notice that position starts at 0 at the outside interface;
310
310
  * inside XPath expressions this shows up as position()=1.
311
- * @param nodeList TODO
312
- * @param opt_position TODO
313
- * @param opt_parent TODO
314
- * @param opt_caseInsensitive TODO
315
- * @param opt_ignoreAttributesWithoutValue TODO
316
- * @param opt_returnOnFirstMatch TODO
317
- * @param opt_ignoreNonElementNodesForNTA TODO
311
+ * @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.
312
+ * @param xsltVersion The XSLT version in use, which may affect certain function behaviors (e.g. 1.0 vs 2.0).
313
+ * @param opt_position The position of the current node in the nodeList. Defaults to 0.
314
+ * @param opt_parent The parent expression context, used for variable scoping. Defaults to null.
315
+ * @param opt_caseInsensitive Whether node name tests should be case insensitive. Defaults to false.
316
+ * @param opt_ignoreAttributesWithoutValue Whether to ignore attributes that have no value (e.g. <input disabled>) when evaluating XPath expressions. Defaults to false.
317
+ * @param opt_returnOnFirstMatch Whether XPath evaluation should return as soon as the first match is found. Defaults to false.
318
+ * @param opt_ignoreNonElementNodesForNTA Whether to ignore non-element nodes when evaluating the "node()" any node test. Defaults to false.
318
319
  */
319
320
  constructor(nodeList: XNode[], xsltVersion?: '1.0' | '2.0' | '3.0', opt_position?: number, opt_decimalFormatSettings?: XsltDecimalFormatSettings, opt_variables?: {
320
321
  [name: string]: any;
@@ -326,9 +327,9 @@ declare class ExprContext {
326
327
  * parent. If passed as argument to clone(), the new context has a
327
328
  * different node, position, or node set. What is not passed is
328
329
  * inherited from the cloned context.
329
- * @param opt_nodeList TODO
330
- * @param opt_position TODO
331
- * @returns TODO
330
+ * @param opt_nodeList The node list for the new context. If not provided, the new context inherits the node list of the current context.
331
+ * @param opt_position The position for the new context. If not provided, the new context inherits the position of the current context.
332
+ * @returns A new ExprContext instance with the specified node list and position, and the current context as its parent.
332
333
  */
333
334
  clone(opt_nodeList?: XNode[], opt_position?: number): ExprContext;
334
335
  setVariable(name?: string, value?: NodeValue | string): void;
@@ -343,13 +344,13 @@ declare class ExprContext {
343
344
  setNode(position: number): void;
344
345
  contextSize(): number;
345
346
  isCaseInsensitive(): any;
346
- setCaseInsensitive(caseInsensitive: any): any;
347
- isIgnoreAttributesWithoutValue(): any;
348
- setIgnoreAttributesWithoutValue(ignore: any): any;
349
- isReturnOnFirstMatch(): any;
350
- setReturnOnFirstMatch(returnOnFirstMatch: any): any;
351
- isIgnoreNonElementNodesForNTA(): any;
352
- setIgnoreNonElementNodesForNTA(ignoreNonElementNodesForNTA: any): any;
347
+ setCaseInsensitive(caseInsensitive: boolean): boolean;
348
+ isIgnoreAttributesWithoutValue(): boolean;
349
+ setIgnoreAttributesWithoutValue(ignore: boolean): boolean;
350
+ isReturnOnFirstMatch(): boolean;
351
+ setReturnOnFirstMatch(returnOnFirstMatch: boolean): boolean;
352
+ isIgnoreNonElementNodesForNTA(): boolean;
353
+ setIgnoreNonElementNodesForNTA(ignoreNonElementNodesForNTA: boolean): boolean;
353
354
  }
354
355
 
355
356
  /**
package/index.d.ts CHANGED
@@ -308,13 +308,14 @@ declare class ExprContext {
308
308
  *
309
309
  * Notice that position starts at 0 at the outside interface;
310
310
  * inside XPath expressions this shows up as position()=1.
311
- * @param nodeList TODO
312
- * @param opt_position TODO
313
- * @param opt_parent TODO
314
- * @param opt_caseInsensitive TODO
315
- * @param opt_ignoreAttributesWithoutValue TODO
316
- * @param opt_returnOnFirstMatch TODO
317
- * @param opt_ignoreNonElementNodesForNTA TODO
311
+ * @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.
312
+ * @param xsltVersion The XSLT version in use, which may affect certain function behaviors (e.g. 1.0 vs 2.0).
313
+ * @param opt_position The position of the current node in the nodeList. Defaults to 0.
314
+ * @param opt_parent The parent expression context, used for variable scoping. Defaults to null.
315
+ * @param opt_caseInsensitive Whether node name tests should be case insensitive. Defaults to false.
316
+ * @param opt_ignoreAttributesWithoutValue Whether to ignore attributes that have no value (e.g. <input disabled>) when evaluating XPath expressions. Defaults to false.
317
+ * @param opt_returnOnFirstMatch Whether XPath evaluation should return as soon as the first match is found. Defaults to false.
318
+ * @param opt_ignoreNonElementNodesForNTA Whether to ignore non-element nodes when evaluating the "node()" any node test. Defaults to false.
318
319
  */
319
320
  constructor(nodeList: XNode[], xsltVersion?: '1.0' | '2.0' | '3.0', opt_position?: number, opt_decimalFormatSettings?: XsltDecimalFormatSettings, opt_variables?: {
320
321
  [name: string]: any;
@@ -326,9 +327,9 @@ declare class ExprContext {
326
327
  * parent. If passed as argument to clone(), the new context has a
327
328
  * different node, position, or node set. What is not passed is
328
329
  * inherited from the cloned context.
329
- * @param opt_nodeList TODO
330
- * @param opt_position TODO
331
- * @returns TODO
330
+ * @param opt_nodeList The node list for the new context. If not provided, the new context inherits the node list of the current context.
331
+ * @param opt_position The position for the new context. If not provided, the new context inherits the position of the current context.
332
+ * @returns A new ExprContext instance with the specified node list and position, and the current context as its parent.
332
333
  */
333
334
  clone(opt_nodeList?: XNode[], opt_position?: number): ExprContext;
334
335
  setVariable(name?: string, value?: NodeValue | string): void;
@@ -343,13 +344,13 @@ declare class ExprContext {
343
344
  setNode(position: number): void;
344
345
  contextSize(): number;
345
346
  isCaseInsensitive(): any;
346
- setCaseInsensitive(caseInsensitive: any): any;
347
- isIgnoreAttributesWithoutValue(): any;
348
- setIgnoreAttributesWithoutValue(ignore: any): any;
349
- isReturnOnFirstMatch(): any;
350
- setReturnOnFirstMatch(returnOnFirstMatch: any): any;
351
- isIgnoreNonElementNodesForNTA(): any;
352
- setIgnoreNonElementNodesForNTA(ignoreNonElementNodesForNTA: any): any;
347
+ setCaseInsensitive(caseInsensitive: boolean): boolean;
348
+ isIgnoreAttributesWithoutValue(): boolean;
349
+ setIgnoreAttributesWithoutValue(ignore: boolean): boolean;
350
+ isReturnOnFirstMatch(): boolean;
351
+ setReturnOnFirstMatch(returnOnFirstMatch: boolean): boolean;
352
+ isIgnoreNonElementNodesForNTA(): boolean;
353
+ setIgnoreNonElementNodesForNTA(ignoreNonElementNodesForNTA: boolean): boolean;
353
354
  }
354
355
 
355
356
  /**
package/index.js 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 Number(this.stringValue([], context));
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 Number(stringValue);
6471
+ return toNumberFromString(stringValue);
6472
+ }
6473
+ if (typeof value === "string") {
6474
+ return toNumberFromString(value);
6465
6475
  }
6466
6476
  return Number(value);
6467
6477
  }
@@ -11633,7 +11643,11 @@ var StringValue = class {
11633
11643
  return this.value.length > 0;
11634
11644
  }
11635
11645
  numberValue() {
11636
- return this.value - 0;
11646
+ const text = String(this.value).trim();
11647
+ if (text.length === 0) {
11648
+ return NaN;
11649
+ }
11650
+ return Number(text);
11637
11651
  }
11638
11652
  nodeSetValue() {
11639
11653
  throw this;
@@ -12432,13 +12446,14 @@ var ExprContext = class _ExprContext {
12432
12446
  *
12433
12447
  * Notice that position starts at 0 at the outside interface;
12434
12448
  * inside XPath expressions this shows up as position()=1.
12435
- * @param nodeList TODO
12436
- * @param opt_position TODO
12437
- * @param opt_parent TODO
12438
- * @param opt_caseInsensitive TODO
12439
- * @param opt_ignoreAttributesWithoutValue TODO
12440
- * @param opt_returnOnFirstMatch TODO
12441
- * @param opt_ignoreNonElementNodesForNTA TODO
12449
+ * @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.
12450
+ * @param xsltVersion The XSLT version in use, which may affect certain function behaviors (e.g. 1.0 vs 2.0).
12451
+ * @param opt_position The position of the current node in the nodeList. Defaults to 0.
12452
+ * @param opt_parent The parent expression context, used for variable scoping. Defaults to null.
12453
+ * @param opt_caseInsensitive Whether node name tests should be case insensitive. Defaults to false.
12454
+ * @param opt_ignoreAttributesWithoutValue Whether to ignore attributes that have no value (e.g. <input disabled>) when evaluating XPath expressions. Defaults to false.
12455
+ * @param opt_returnOnFirstMatch Whether XPath evaluation should return as soon as the first match is found. Defaults to false.
12456
+ * @param opt_ignoreNonElementNodesForNTA Whether to ignore non-element nodes when evaluating the "node()" any node test. Defaults to false.
12442
12457
  */
12443
12458
  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) {
12444
12459
  this.nodeList = nodeList;
@@ -12480,9 +12495,9 @@ var ExprContext = class _ExprContext {
12480
12495
  * parent. If passed as argument to clone(), the new context has a
12481
12496
  * different node, position, or node set. What is not passed is
12482
12497
  * inherited from the cloned context.
12483
- * @param opt_nodeList TODO
12484
- * @param opt_position TODO
12485
- * @returns TODO
12498
+ * @param opt_nodeList The node list for the new context. If not provided, the new context inherits the node list of the current context.
12499
+ * @param opt_position The position for the new context. If not provided, the new context inherits the position of the current context.
12500
+ * @returns A new ExprContext instance with the specified node list and position, and the current context as its parent.
12486
12501
  */
12487
12502
  clone(opt_nodeList, opt_position) {
12488
12503
  return new _ExprContext(