xslt-processor 4.5.0 → 4.6.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/index.d.mts +181 -7
- package/index.d.ts +181 -7
- package/index.js +5523 -1315
- package/index.js.map +1 -1
- package/index.mjs +5514 -1306
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/umd/xslt-processor.global.js +3 -2
- package/umd/xslt-processor.global.js.map +1 -1
package/index.d.mts
CHANGED
|
@@ -170,6 +170,21 @@ type XPathFunctions = Record<string, XPathFunction>;
|
|
|
170
170
|
* Type for namespace bindings (prefix -> namespace URI).
|
|
171
171
|
*/
|
|
172
172
|
type XPathNamespaces = Record<string, string>;
|
|
173
|
+
/**
|
|
174
|
+
* Type for available documents mapping (URI -> root node).
|
|
175
|
+
* Used by fn:doc() and related functions (XPath 2.0+).
|
|
176
|
+
*/
|
|
177
|
+
type XPathDocuments = Record<string, XPathNode | null>;
|
|
178
|
+
/**
|
|
179
|
+
* Type for available collections mapping (URI -> sequence of nodes).
|
|
180
|
+
* Used by fn:collection() function (XPath 2.0+).
|
|
181
|
+
*/
|
|
182
|
+
type XPathCollections = Record<string, XPathNode[]>;
|
|
183
|
+
/**
|
|
184
|
+
* Type for function implementations registry.
|
|
185
|
+
* Maps function names (with optional namespace) to their implementations.
|
|
186
|
+
*/
|
|
187
|
+
type XPathFunctionRegistry = Record<string, XPathFunction>;
|
|
173
188
|
/**
|
|
174
189
|
* The evaluation context for XPath expressions.
|
|
175
190
|
*
|
|
@@ -178,6 +193,7 @@ type XPathNamespaces = Record<string, string>;
|
|
|
178
193
|
* - Position information for predicates
|
|
179
194
|
* - Variable bindings
|
|
180
195
|
* - Custom function definitions
|
|
196
|
+
* - Dynamic properties like current dateTime, available documents, etc.
|
|
181
197
|
*/
|
|
182
198
|
interface XPathContext {
|
|
183
199
|
/**
|
|
@@ -220,11 +236,96 @@ interface XPathContext {
|
|
|
220
236
|
* Used by functions like json-to-xml() which are only available in XSLT 3.0+
|
|
221
237
|
*/
|
|
222
238
|
xsltVersion?: string;
|
|
239
|
+
/**
|
|
240
|
+
* XPath specification version being used.
|
|
241
|
+
* Default: '1.0'
|
|
242
|
+
*
|
|
243
|
+
* This affects:
|
|
244
|
+
* - Function library available
|
|
245
|
+
* - Type system behavior
|
|
246
|
+
* - Sequence vs node-set handling
|
|
247
|
+
*/
|
|
248
|
+
xpathVersion?: '1.0' | '2.0' | '3.0' | '3.1';
|
|
249
|
+
/**
|
|
250
|
+
* Enable XPath 1.0 backward compatibility mode (Phase 8.1).
|
|
251
|
+
* When true, XPath 2.0+ expressions follow XPath 1.0 type conversion rules.
|
|
252
|
+
* This enables:
|
|
253
|
+
* - XPath 1.0 boolean conversion semantics
|
|
254
|
+
* - XPath 1.0 numeric conversion (with NaN for empty sequences)
|
|
255
|
+
* - XPath 1.0 comparison rules (node-set to string conversion)
|
|
256
|
+
* - XPath 1.0 logical operator behavior (short-circuit, error suppression)
|
|
257
|
+
* Default: false (XPath 2.0 semantics)
|
|
258
|
+
*/
|
|
259
|
+
xpath10CompatibilityMode?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Default collation for string comparisons (XPath 2.0+).
|
|
262
|
+
* Default: Unicode codepoint collation
|
|
263
|
+
*/
|
|
264
|
+
defaultCollation?: string;
|
|
265
|
+
/**
|
|
266
|
+
* Base URI for resolving relative URIs (XPath 2.0+).
|
|
267
|
+
*/
|
|
268
|
+
baseUri?: string;
|
|
269
|
+
/**
|
|
270
|
+
* Implicit timezone as duration offset from UTC (XPath 2.0+).
|
|
271
|
+
* Example: '-PT5H' for US Eastern Time (UTC-5)
|
|
272
|
+
*/
|
|
273
|
+
implicitTimezone?: string;
|
|
274
|
+
/**
|
|
275
|
+
* Extension data for XSLT or custom implementations.
|
|
276
|
+
* This allows attaching arbitrary data to the context without
|
|
277
|
+
* polluting the main interface.
|
|
278
|
+
*/
|
|
279
|
+
extensions?: Record<string, any>;
|
|
280
|
+
/**
|
|
281
|
+
* Current dateTime in the dynamic context (XPath 2.0+).
|
|
282
|
+
* Returned by fn:current-dateTime().
|
|
283
|
+
* If not provided, defaults to system time when accessed.
|
|
284
|
+
*/
|
|
285
|
+
currentDateTime?: Date;
|
|
286
|
+
/**
|
|
287
|
+
* Available documents mapping for fn:doc() function (XPath 2.0+).
|
|
288
|
+
* Maps document URIs to their root document nodes.
|
|
289
|
+
* Example: { "http://example.com/data.xml": rootNode }
|
|
290
|
+
*/
|
|
291
|
+
availableDocuments?: XPathDocuments;
|
|
292
|
+
/**
|
|
293
|
+
* Available collections mapping for fn:collection() function (XPath 2.0+).
|
|
294
|
+
* Maps collection URIs to sequences of nodes.
|
|
295
|
+
* Example: { "http://example.com/collection": [node1, node2, ...] }
|
|
296
|
+
*/
|
|
297
|
+
availableCollections?: XPathCollections;
|
|
298
|
+
/**
|
|
299
|
+
* Default collection URI when fn:collection() is called without arguments (XPath 2.0+).
|
|
300
|
+
* If provided, fn:collection() returns availableCollections[defaultCollection].
|
|
301
|
+
*/
|
|
302
|
+
defaultCollection?: string;
|
|
303
|
+
/**
|
|
304
|
+
* Function implementations registry (XPath 2.0+).
|
|
305
|
+
* Maps QName function names to their implementations.
|
|
306
|
+
* Allows defining custom/XSLT functions at evaluation time.
|
|
307
|
+
* Format: "localName" or "prefix:localName"
|
|
308
|
+
*/
|
|
309
|
+
functionRegistry?: XPathFunctionRegistry;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Represents an XPath 3.0 function item.
|
|
313
|
+
* This is a simplified interface to avoid circular dependencies.
|
|
314
|
+
*/
|
|
315
|
+
interface XPathFunctionItem {
|
|
316
|
+
__isFunctionItem: true;
|
|
317
|
+
implementation: (...args: any[]) => any;
|
|
318
|
+
arity: number;
|
|
319
|
+
name?: string;
|
|
320
|
+
namespace?: string;
|
|
223
321
|
}
|
|
224
322
|
/**
|
|
225
323
|
* Result types that can be returned from XPath evaluation.
|
|
324
|
+
*
|
|
325
|
+
* XPath 1.0: node-set, string, number, boolean
|
|
326
|
+
* XPath 2.0+: sequences (which subsume node-sets), atomic values, functions
|
|
226
327
|
*/
|
|
227
|
-
type XPathResult = XPathNode[] | string | number | boolean;
|
|
328
|
+
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null | XPathFunctionItem;
|
|
228
329
|
|
|
229
330
|
declare abstract class XPathExpression {
|
|
230
331
|
abstract evaluate(context: XPathContext): XPathResult;
|
|
@@ -315,6 +416,25 @@ declare class ExprContext {
|
|
|
315
416
|
knownNamespaces: {
|
|
316
417
|
[alias: string]: string;
|
|
317
418
|
};
|
|
419
|
+
/**
|
|
420
|
+
* Custom system properties for system-property() function.
|
|
421
|
+
* Overrides the default properties (xsl:version, xsl:vendor, xsl:vendor-url).
|
|
422
|
+
*/
|
|
423
|
+
systemProperties?: {
|
|
424
|
+
[name: string]: string;
|
|
425
|
+
};
|
|
426
|
+
/**
|
|
427
|
+
* Document loader function for the document() function.
|
|
428
|
+
* Takes a URI and returns an XNode document, or null if loading fails.
|
|
429
|
+
*/
|
|
430
|
+
documentLoader?: (uri: string) => XNode | null;
|
|
431
|
+
/**
|
|
432
|
+
* Unparsed entity URIs for the unparsed-entity-uri() function.
|
|
433
|
+
* Maps entity names to their URIs (from DTD declarations).
|
|
434
|
+
*/
|
|
435
|
+
unparsedEntities?: {
|
|
436
|
+
[name: string]: string;
|
|
437
|
+
};
|
|
318
438
|
caseInsensitive: any;
|
|
319
439
|
ignoreAttributesWithoutValue: any;
|
|
320
440
|
returnOnFirstMatch: any;
|
|
@@ -417,6 +537,8 @@ declare class NodeConverter {
|
|
|
417
537
|
private convertVariables;
|
|
418
538
|
/**
|
|
419
539
|
* Create custom functions for XPath context (like key(), document(), etc.).
|
|
540
|
+
* Note: Custom functions receive the XPathContext as their first argument,
|
|
541
|
+
* followed by the evaluated function arguments.
|
|
420
542
|
*/
|
|
421
543
|
private createCustomFunctions;
|
|
422
544
|
/**
|
|
@@ -583,6 +705,15 @@ declare class Xslt {
|
|
|
583
705
|
outputOmitXmlDeclaration: string;
|
|
584
706
|
version: string;
|
|
585
707
|
firstTemplateRan: boolean;
|
|
708
|
+
/**
|
|
709
|
+
* Forwards-compatible processing mode (XSLT 1.0 Section 2.5).
|
|
710
|
+
* When true, the processor is running a stylesheet with version > 1.0.
|
|
711
|
+
* In this mode:
|
|
712
|
+
* - Unknown top-level elements are silently ignored
|
|
713
|
+
* - Unknown XSLT instructions use xsl:fallback if available, otherwise are ignored
|
|
714
|
+
* - Unknown attributes on XSLT elements are ignored
|
|
715
|
+
*/
|
|
716
|
+
forwardsCompatible: boolean;
|
|
586
717
|
/**
|
|
587
718
|
* List of element name patterns from xsl:strip-space declarations.
|
|
588
719
|
* Whitespace-only text nodes inside matching elements will be stripped.
|
|
@@ -645,6 +776,21 @@ declare class Xslt {
|
|
|
645
776
|
* @param output If set, the output where the transformation should occur.
|
|
646
777
|
*/
|
|
647
778
|
protected xsltProcessContext(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
779
|
+
/**
|
|
780
|
+
* Handle unknown XSLT instructions per XSLT 1.0 Section 2.5 (Forwards-Compatible Processing).
|
|
781
|
+
*
|
|
782
|
+
* In forwards-compatible mode (version > 1.0):
|
|
783
|
+
* - If the instruction has an xsl:fallback child, execute the fallback
|
|
784
|
+
* - Otherwise, the instruction is silently ignored
|
|
785
|
+
*
|
|
786
|
+
* In strict mode (version = 1.0):
|
|
787
|
+
* - Unknown instructions are an error
|
|
788
|
+
*
|
|
789
|
+
* @param context The Expression Context
|
|
790
|
+
* @param template The unknown XSLT instruction element
|
|
791
|
+
* @param output The output node
|
|
792
|
+
*/
|
|
793
|
+
protected xsltUnknownInstruction(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
648
794
|
/**
|
|
649
795
|
* Implements `xsl:apply-templates`.
|
|
650
796
|
* @param context The Expression Context.
|
|
@@ -798,29 +944,57 @@ declare class Xslt {
|
|
|
798
944
|
* @param context The Expression Context.
|
|
799
945
|
* @param level The counting level: 'single', 'multiple', or 'any'.
|
|
800
946
|
* @param count Pattern to match nodes to count.
|
|
801
|
-
* @param from Pattern to
|
|
802
|
-
* @returns
|
|
947
|
+
* @param from Pattern to define counting boundary.
|
|
948
|
+
* @returns Array of count values (single element for 'single'/'any', multiple for 'multiple').
|
|
803
949
|
*/
|
|
804
|
-
protected xsltNumberCount(context: ExprContext, level: string, count: string | null, from: string | null): number;
|
|
950
|
+
protected xsltNumberCount(context: ExprContext, level: string, count: string | null, from: string | null): number[];
|
|
805
951
|
/**
|
|
806
|
-
* Checks if a node matches a simple
|
|
952
|
+
* Checks if a node matches a pattern (supports simple names and union patterns).
|
|
807
953
|
* @param node The node to check.
|
|
808
|
-
* @param pattern The pattern (node name
|
|
954
|
+
* @param pattern The pattern (node name, wildcard, or union like "a|b|c").
|
|
809
955
|
* @returns True if the node matches.
|
|
810
956
|
*/
|
|
811
957
|
protected nodeMatchesPattern(node: XNode, pattern: string): boolean;
|
|
958
|
+
/**
|
|
959
|
+
* Checks if a node matches a single (non-union) pattern.
|
|
960
|
+
* @param node The node to check.
|
|
961
|
+
* @param pattern The pattern (node name or wildcard).
|
|
962
|
+
* @returns True if the node matches.
|
|
963
|
+
*/
|
|
964
|
+
protected nodeMatchesSinglePattern(node: XNode, pattern: string): boolean;
|
|
812
965
|
/**
|
|
813
966
|
* Gets all nodes preceding the given node in document order.
|
|
814
967
|
* @param node The reference node.
|
|
968
|
+
* @param fromPattern Optional pattern to define counting boundary.
|
|
815
969
|
* @returns Array of preceding nodes.
|
|
816
970
|
*/
|
|
817
|
-
protected getAllPrecedingNodes(node: XNode): XNode[];
|
|
971
|
+
protected getAllPrecedingNodes(node: XNode, fromPattern?: string | null): XNode[];
|
|
818
972
|
/**
|
|
819
973
|
* Collects all descendant nodes of a given node.
|
|
820
974
|
* @param node The parent node.
|
|
821
975
|
* @param result The array to collect into.
|
|
822
976
|
*/
|
|
823
977
|
protected collectDescendants(node: XNode, result: XNode[]): void;
|
|
978
|
+
/**
|
|
979
|
+
* Formats an array of numbers according to the format string.
|
|
980
|
+
* For level="multiple", numbers like [1, 2, 3] with format "1.1.1" produce "1.2.3".
|
|
981
|
+
* @param numbers The numbers to format.
|
|
982
|
+
* @param format The format string (e.g., "1", "1.1", "1.a.i").
|
|
983
|
+
* @param groupingSeparator Optional grouping separator.
|
|
984
|
+
* @param groupingSize Optional grouping size.
|
|
985
|
+
* @returns The formatted number string.
|
|
986
|
+
*/
|
|
987
|
+
protected xsltFormatNumbers(numbers: number[], format: string, groupingSeparator: string | null, groupingSize: string | null): string;
|
|
988
|
+
/**
|
|
989
|
+
* Parses a format string into tokens and separators.
|
|
990
|
+
* E.g., "1.a.i" -> tokens: ["1", "a", "i"], separators: [".", "."]
|
|
991
|
+
* @param format The format string.
|
|
992
|
+
* @returns Object with tokens and separators arrays.
|
|
993
|
+
*/
|
|
994
|
+
protected parseFormatString(format: string): {
|
|
995
|
+
tokens: string[];
|
|
996
|
+
separators: string[];
|
|
997
|
+
};
|
|
824
998
|
/**
|
|
825
999
|
* Formats a number according to the format string.
|
|
826
1000
|
* @param number The number to format.
|
package/index.d.ts
CHANGED
|
@@ -170,6 +170,21 @@ type XPathFunctions = Record<string, XPathFunction>;
|
|
|
170
170
|
* Type for namespace bindings (prefix -> namespace URI).
|
|
171
171
|
*/
|
|
172
172
|
type XPathNamespaces = Record<string, string>;
|
|
173
|
+
/**
|
|
174
|
+
* Type for available documents mapping (URI -> root node).
|
|
175
|
+
* Used by fn:doc() and related functions (XPath 2.0+).
|
|
176
|
+
*/
|
|
177
|
+
type XPathDocuments = Record<string, XPathNode | null>;
|
|
178
|
+
/**
|
|
179
|
+
* Type for available collections mapping (URI -> sequence of nodes).
|
|
180
|
+
* Used by fn:collection() function (XPath 2.0+).
|
|
181
|
+
*/
|
|
182
|
+
type XPathCollections = Record<string, XPathNode[]>;
|
|
183
|
+
/**
|
|
184
|
+
* Type for function implementations registry.
|
|
185
|
+
* Maps function names (with optional namespace) to their implementations.
|
|
186
|
+
*/
|
|
187
|
+
type XPathFunctionRegistry = Record<string, XPathFunction>;
|
|
173
188
|
/**
|
|
174
189
|
* The evaluation context for XPath expressions.
|
|
175
190
|
*
|
|
@@ -178,6 +193,7 @@ type XPathNamespaces = Record<string, string>;
|
|
|
178
193
|
* - Position information for predicates
|
|
179
194
|
* - Variable bindings
|
|
180
195
|
* - Custom function definitions
|
|
196
|
+
* - Dynamic properties like current dateTime, available documents, etc.
|
|
181
197
|
*/
|
|
182
198
|
interface XPathContext {
|
|
183
199
|
/**
|
|
@@ -220,11 +236,96 @@ interface XPathContext {
|
|
|
220
236
|
* Used by functions like json-to-xml() which are only available in XSLT 3.0+
|
|
221
237
|
*/
|
|
222
238
|
xsltVersion?: string;
|
|
239
|
+
/**
|
|
240
|
+
* XPath specification version being used.
|
|
241
|
+
* Default: '1.0'
|
|
242
|
+
*
|
|
243
|
+
* This affects:
|
|
244
|
+
* - Function library available
|
|
245
|
+
* - Type system behavior
|
|
246
|
+
* - Sequence vs node-set handling
|
|
247
|
+
*/
|
|
248
|
+
xpathVersion?: '1.0' | '2.0' | '3.0' | '3.1';
|
|
249
|
+
/**
|
|
250
|
+
* Enable XPath 1.0 backward compatibility mode (Phase 8.1).
|
|
251
|
+
* When true, XPath 2.0+ expressions follow XPath 1.0 type conversion rules.
|
|
252
|
+
* This enables:
|
|
253
|
+
* - XPath 1.0 boolean conversion semantics
|
|
254
|
+
* - XPath 1.0 numeric conversion (with NaN for empty sequences)
|
|
255
|
+
* - XPath 1.0 comparison rules (node-set to string conversion)
|
|
256
|
+
* - XPath 1.0 logical operator behavior (short-circuit, error suppression)
|
|
257
|
+
* Default: false (XPath 2.0 semantics)
|
|
258
|
+
*/
|
|
259
|
+
xpath10CompatibilityMode?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Default collation for string comparisons (XPath 2.0+).
|
|
262
|
+
* Default: Unicode codepoint collation
|
|
263
|
+
*/
|
|
264
|
+
defaultCollation?: string;
|
|
265
|
+
/**
|
|
266
|
+
* Base URI for resolving relative URIs (XPath 2.0+).
|
|
267
|
+
*/
|
|
268
|
+
baseUri?: string;
|
|
269
|
+
/**
|
|
270
|
+
* Implicit timezone as duration offset from UTC (XPath 2.0+).
|
|
271
|
+
* Example: '-PT5H' for US Eastern Time (UTC-5)
|
|
272
|
+
*/
|
|
273
|
+
implicitTimezone?: string;
|
|
274
|
+
/**
|
|
275
|
+
* Extension data for XSLT or custom implementations.
|
|
276
|
+
* This allows attaching arbitrary data to the context without
|
|
277
|
+
* polluting the main interface.
|
|
278
|
+
*/
|
|
279
|
+
extensions?: Record<string, any>;
|
|
280
|
+
/**
|
|
281
|
+
* Current dateTime in the dynamic context (XPath 2.0+).
|
|
282
|
+
* Returned by fn:current-dateTime().
|
|
283
|
+
* If not provided, defaults to system time when accessed.
|
|
284
|
+
*/
|
|
285
|
+
currentDateTime?: Date;
|
|
286
|
+
/**
|
|
287
|
+
* Available documents mapping for fn:doc() function (XPath 2.0+).
|
|
288
|
+
* Maps document URIs to their root document nodes.
|
|
289
|
+
* Example: { "http://example.com/data.xml": rootNode }
|
|
290
|
+
*/
|
|
291
|
+
availableDocuments?: XPathDocuments;
|
|
292
|
+
/**
|
|
293
|
+
* Available collections mapping for fn:collection() function (XPath 2.0+).
|
|
294
|
+
* Maps collection URIs to sequences of nodes.
|
|
295
|
+
* Example: { "http://example.com/collection": [node1, node2, ...] }
|
|
296
|
+
*/
|
|
297
|
+
availableCollections?: XPathCollections;
|
|
298
|
+
/**
|
|
299
|
+
* Default collection URI when fn:collection() is called without arguments (XPath 2.0+).
|
|
300
|
+
* If provided, fn:collection() returns availableCollections[defaultCollection].
|
|
301
|
+
*/
|
|
302
|
+
defaultCollection?: string;
|
|
303
|
+
/**
|
|
304
|
+
* Function implementations registry (XPath 2.0+).
|
|
305
|
+
* Maps QName function names to their implementations.
|
|
306
|
+
* Allows defining custom/XSLT functions at evaluation time.
|
|
307
|
+
* Format: "localName" or "prefix:localName"
|
|
308
|
+
*/
|
|
309
|
+
functionRegistry?: XPathFunctionRegistry;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Represents an XPath 3.0 function item.
|
|
313
|
+
* This is a simplified interface to avoid circular dependencies.
|
|
314
|
+
*/
|
|
315
|
+
interface XPathFunctionItem {
|
|
316
|
+
__isFunctionItem: true;
|
|
317
|
+
implementation: (...args: any[]) => any;
|
|
318
|
+
arity: number;
|
|
319
|
+
name?: string;
|
|
320
|
+
namespace?: string;
|
|
223
321
|
}
|
|
224
322
|
/**
|
|
225
323
|
* Result types that can be returned from XPath evaluation.
|
|
324
|
+
*
|
|
325
|
+
* XPath 1.0: node-set, string, number, boolean
|
|
326
|
+
* XPath 2.0+: sequences (which subsume node-sets), atomic values, functions
|
|
226
327
|
*/
|
|
227
|
-
type XPathResult = XPathNode[] | string | number | boolean;
|
|
328
|
+
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null | XPathFunctionItem;
|
|
228
329
|
|
|
229
330
|
declare abstract class XPathExpression {
|
|
230
331
|
abstract evaluate(context: XPathContext): XPathResult;
|
|
@@ -315,6 +416,25 @@ declare class ExprContext {
|
|
|
315
416
|
knownNamespaces: {
|
|
316
417
|
[alias: string]: string;
|
|
317
418
|
};
|
|
419
|
+
/**
|
|
420
|
+
* Custom system properties for system-property() function.
|
|
421
|
+
* Overrides the default properties (xsl:version, xsl:vendor, xsl:vendor-url).
|
|
422
|
+
*/
|
|
423
|
+
systemProperties?: {
|
|
424
|
+
[name: string]: string;
|
|
425
|
+
};
|
|
426
|
+
/**
|
|
427
|
+
* Document loader function for the document() function.
|
|
428
|
+
* Takes a URI and returns an XNode document, or null if loading fails.
|
|
429
|
+
*/
|
|
430
|
+
documentLoader?: (uri: string) => XNode | null;
|
|
431
|
+
/**
|
|
432
|
+
* Unparsed entity URIs for the unparsed-entity-uri() function.
|
|
433
|
+
* Maps entity names to their URIs (from DTD declarations).
|
|
434
|
+
*/
|
|
435
|
+
unparsedEntities?: {
|
|
436
|
+
[name: string]: string;
|
|
437
|
+
};
|
|
318
438
|
caseInsensitive: any;
|
|
319
439
|
ignoreAttributesWithoutValue: any;
|
|
320
440
|
returnOnFirstMatch: any;
|
|
@@ -417,6 +537,8 @@ declare class NodeConverter {
|
|
|
417
537
|
private convertVariables;
|
|
418
538
|
/**
|
|
419
539
|
* Create custom functions for XPath context (like key(), document(), etc.).
|
|
540
|
+
* Note: Custom functions receive the XPathContext as their first argument,
|
|
541
|
+
* followed by the evaluated function arguments.
|
|
420
542
|
*/
|
|
421
543
|
private createCustomFunctions;
|
|
422
544
|
/**
|
|
@@ -583,6 +705,15 @@ declare class Xslt {
|
|
|
583
705
|
outputOmitXmlDeclaration: string;
|
|
584
706
|
version: string;
|
|
585
707
|
firstTemplateRan: boolean;
|
|
708
|
+
/**
|
|
709
|
+
* Forwards-compatible processing mode (XSLT 1.0 Section 2.5).
|
|
710
|
+
* When true, the processor is running a stylesheet with version > 1.0.
|
|
711
|
+
* In this mode:
|
|
712
|
+
* - Unknown top-level elements are silently ignored
|
|
713
|
+
* - Unknown XSLT instructions use xsl:fallback if available, otherwise are ignored
|
|
714
|
+
* - Unknown attributes on XSLT elements are ignored
|
|
715
|
+
*/
|
|
716
|
+
forwardsCompatible: boolean;
|
|
586
717
|
/**
|
|
587
718
|
* List of element name patterns from xsl:strip-space declarations.
|
|
588
719
|
* Whitespace-only text nodes inside matching elements will be stripped.
|
|
@@ -645,6 +776,21 @@ declare class Xslt {
|
|
|
645
776
|
* @param output If set, the output where the transformation should occur.
|
|
646
777
|
*/
|
|
647
778
|
protected xsltProcessContext(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
779
|
+
/**
|
|
780
|
+
* Handle unknown XSLT instructions per XSLT 1.0 Section 2.5 (Forwards-Compatible Processing).
|
|
781
|
+
*
|
|
782
|
+
* In forwards-compatible mode (version > 1.0):
|
|
783
|
+
* - If the instruction has an xsl:fallback child, execute the fallback
|
|
784
|
+
* - Otherwise, the instruction is silently ignored
|
|
785
|
+
*
|
|
786
|
+
* In strict mode (version = 1.0):
|
|
787
|
+
* - Unknown instructions are an error
|
|
788
|
+
*
|
|
789
|
+
* @param context The Expression Context
|
|
790
|
+
* @param template The unknown XSLT instruction element
|
|
791
|
+
* @param output The output node
|
|
792
|
+
*/
|
|
793
|
+
protected xsltUnknownInstruction(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
648
794
|
/**
|
|
649
795
|
* Implements `xsl:apply-templates`.
|
|
650
796
|
* @param context The Expression Context.
|
|
@@ -798,29 +944,57 @@ declare class Xslt {
|
|
|
798
944
|
* @param context The Expression Context.
|
|
799
945
|
* @param level The counting level: 'single', 'multiple', or 'any'.
|
|
800
946
|
* @param count Pattern to match nodes to count.
|
|
801
|
-
* @param from Pattern to
|
|
802
|
-
* @returns
|
|
947
|
+
* @param from Pattern to define counting boundary.
|
|
948
|
+
* @returns Array of count values (single element for 'single'/'any', multiple for 'multiple').
|
|
803
949
|
*/
|
|
804
|
-
protected xsltNumberCount(context: ExprContext, level: string, count: string | null, from: string | null): number;
|
|
950
|
+
protected xsltNumberCount(context: ExprContext, level: string, count: string | null, from: string | null): number[];
|
|
805
951
|
/**
|
|
806
|
-
* Checks if a node matches a simple
|
|
952
|
+
* Checks if a node matches a pattern (supports simple names and union patterns).
|
|
807
953
|
* @param node The node to check.
|
|
808
|
-
* @param pattern The pattern (node name
|
|
954
|
+
* @param pattern The pattern (node name, wildcard, or union like "a|b|c").
|
|
809
955
|
* @returns True if the node matches.
|
|
810
956
|
*/
|
|
811
957
|
protected nodeMatchesPattern(node: XNode, pattern: string): boolean;
|
|
958
|
+
/**
|
|
959
|
+
* Checks if a node matches a single (non-union) pattern.
|
|
960
|
+
* @param node The node to check.
|
|
961
|
+
* @param pattern The pattern (node name or wildcard).
|
|
962
|
+
* @returns True if the node matches.
|
|
963
|
+
*/
|
|
964
|
+
protected nodeMatchesSinglePattern(node: XNode, pattern: string): boolean;
|
|
812
965
|
/**
|
|
813
966
|
* Gets all nodes preceding the given node in document order.
|
|
814
967
|
* @param node The reference node.
|
|
968
|
+
* @param fromPattern Optional pattern to define counting boundary.
|
|
815
969
|
* @returns Array of preceding nodes.
|
|
816
970
|
*/
|
|
817
|
-
protected getAllPrecedingNodes(node: XNode): XNode[];
|
|
971
|
+
protected getAllPrecedingNodes(node: XNode, fromPattern?: string | null): XNode[];
|
|
818
972
|
/**
|
|
819
973
|
* Collects all descendant nodes of a given node.
|
|
820
974
|
* @param node The parent node.
|
|
821
975
|
* @param result The array to collect into.
|
|
822
976
|
*/
|
|
823
977
|
protected collectDescendants(node: XNode, result: XNode[]): void;
|
|
978
|
+
/**
|
|
979
|
+
* Formats an array of numbers according to the format string.
|
|
980
|
+
* For level="multiple", numbers like [1, 2, 3] with format "1.1.1" produce "1.2.3".
|
|
981
|
+
* @param numbers The numbers to format.
|
|
982
|
+
* @param format The format string (e.g., "1", "1.1", "1.a.i").
|
|
983
|
+
* @param groupingSeparator Optional grouping separator.
|
|
984
|
+
* @param groupingSize Optional grouping size.
|
|
985
|
+
* @returns The formatted number string.
|
|
986
|
+
*/
|
|
987
|
+
protected xsltFormatNumbers(numbers: number[], format: string, groupingSeparator: string | null, groupingSize: string | null): string;
|
|
988
|
+
/**
|
|
989
|
+
* Parses a format string into tokens and separators.
|
|
990
|
+
* E.g., "1.a.i" -> tokens: ["1", "a", "i"], separators: [".", "."]
|
|
991
|
+
* @param format The format string.
|
|
992
|
+
* @returns Object with tokens and separators arrays.
|
|
993
|
+
*/
|
|
994
|
+
protected parseFormatString(format: string): {
|
|
995
|
+
tokens: string[];
|
|
996
|
+
separators: string[];
|
|
997
|
+
};
|
|
824
998
|
/**
|
|
825
999
|
* Formats a number according to the format string.
|
|
826
1000
|
* @param number The number to format.
|