xslt-processor 4.4.1 → 4.6.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.
- package/index.d.mts +213 -1
- package/index.d.ts +213 -1
- package/index.js +2712 -373
- package/index.js.map +1 -1
- package/index.mjs +2712 -373
- 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
|
@@ -73,6 +73,7 @@ declare class XDocument extends XNode {
|
|
|
73
73
|
createComment(data: any): XNode;
|
|
74
74
|
createCDATASection(data: any): XNode;
|
|
75
75
|
createDTDSection(data: any): XNode;
|
|
76
|
+
createProcessingInstruction(target: string, data: any): XNode;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
/**
|
|
@@ -169,6 +170,21 @@ type XPathFunctions = Record<string, XPathFunction>;
|
|
|
169
170
|
* Type for namespace bindings (prefix -> namespace URI).
|
|
170
171
|
*/
|
|
171
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>;
|
|
172
188
|
/**
|
|
173
189
|
* The evaluation context for XPath expressions.
|
|
174
190
|
*
|
|
@@ -177,6 +193,7 @@ type XPathNamespaces = Record<string, string>;
|
|
|
177
193
|
* - Position information for predicates
|
|
178
194
|
* - Variable bindings
|
|
179
195
|
* - Custom function definitions
|
|
196
|
+
* - Dynamic properties like current dateTime, available documents, etc.
|
|
180
197
|
*/
|
|
181
198
|
interface XPathContext {
|
|
182
199
|
/**
|
|
@@ -219,11 +236,85 @@ interface XPathContext {
|
|
|
219
236
|
* Used by functions like json-to-xml() which are only available in XSLT 3.0+
|
|
220
237
|
*/
|
|
221
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;
|
|
222
310
|
}
|
|
223
311
|
/**
|
|
224
312
|
* Result types that can be returned from XPath evaluation.
|
|
313
|
+
*
|
|
314
|
+
* XPath 1.0: node-set, string, number, boolean
|
|
315
|
+
* XPath 2.0+: sequences (which subsume node-sets), atomic values, functions
|
|
225
316
|
*/
|
|
226
|
-
type XPathResult = XPathNode[] | string | number | boolean;
|
|
317
|
+
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null | Function;
|
|
227
318
|
|
|
228
319
|
declare abstract class XPathExpression {
|
|
229
320
|
abstract evaluate(context: XPathContext): XPathResult;
|
|
@@ -314,6 +405,25 @@ declare class ExprContext {
|
|
|
314
405
|
knownNamespaces: {
|
|
315
406
|
[alias: string]: string;
|
|
316
407
|
};
|
|
408
|
+
/**
|
|
409
|
+
* Custom system properties for system-property() function.
|
|
410
|
+
* Overrides the default properties (xsl:version, xsl:vendor, xsl:vendor-url).
|
|
411
|
+
*/
|
|
412
|
+
systemProperties?: {
|
|
413
|
+
[name: string]: string;
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Document loader function for the document() function.
|
|
417
|
+
* Takes a URI and returns an XNode document, or null if loading fails.
|
|
418
|
+
*/
|
|
419
|
+
documentLoader?: (uri: string) => XNode | null;
|
|
420
|
+
/**
|
|
421
|
+
* Unparsed entity URIs for the unparsed-entity-uri() function.
|
|
422
|
+
* Maps entity names to their URIs (from DTD declarations).
|
|
423
|
+
*/
|
|
424
|
+
unparsedEntities?: {
|
|
425
|
+
[name: string]: string;
|
|
426
|
+
};
|
|
317
427
|
caseInsensitive: any;
|
|
318
428
|
ignoreAttributesWithoutValue: any;
|
|
319
429
|
returnOnFirstMatch: any;
|
|
@@ -416,6 +526,8 @@ declare class NodeConverter {
|
|
|
416
526
|
private convertVariables;
|
|
417
527
|
/**
|
|
418
528
|
* Create custom functions for XPath context (like key(), document(), etc.).
|
|
529
|
+
* Note: Custom functions receive the XPathContext as their first argument,
|
|
530
|
+
* followed by the evaluated function arguments.
|
|
419
531
|
*/
|
|
420
532
|
private createCustomFunctions;
|
|
421
533
|
/**
|
|
@@ -598,6 +710,37 @@ declare class Xslt {
|
|
|
598
710
|
* Maps stylesheet namespace prefixes to result namespace prefixes.
|
|
599
711
|
*/
|
|
600
712
|
namespaceAliases: Map<string, string>;
|
|
713
|
+
/**
|
|
714
|
+
* Set of supported extension element namespaces.
|
|
715
|
+
* Processors can register custom extension namespaces here.
|
|
716
|
+
* Currently only XSLT namespace is auto-registered.
|
|
717
|
+
*/
|
|
718
|
+
supportedExtensions: Set<string>;
|
|
719
|
+
/**
|
|
720
|
+
* Map of attribute sets defined in the stylesheet.
|
|
721
|
+
* Keys are attribute set names, values are arrays of xsl:attribute nodes.
|
|
722
|
+
*/
|
|
723
|
+
attributeSets: Map<string, XNode[]>;
|
|
724
|
+
/**
|
|
725
|
+
* Stack of stylesheet metadata for tracking import hierarchy.
|
|
726
|
+
* Used by apply-imports to find templates from imported stylesheets.
|
|
727
|
+
*/
|
|
728
|
+
private styleSheetStack;
|
|
729
|
+
/**
|
|
730
|
+
* Map of imported stylesheet HREFs to their parsed XNodes.
|
|
731
|
+
* Prevents duplicate imports and allows precedence tracking.
|
|
732
|
+
*/
|
|
733
|
+
private importedStylesheets;
|
|
734
|
+
/**
|
|
735
|
+
* Map templates to the stylesheet they came from.
|
|
736
|
+
* Enables apply-imports to find templates by import precedence.
|
|
737
|
+
*/
|
|
738
|
+
private templateSourceMap;
|
|
739
|
+
/**
|
|
740
|
+
* Stack of currently executing templates with their metadata.
|
|
741
|
+
* Used by apply-imports to determine which template called it.
|
|
742
|
+
*/
|
|
743
|
+
private currentTemplateStack;
|
|
601
744
|
constructor(options?: Partial<XsltOptions>);
|
|
602
745
|
/**
|
|
603
746
|
* The exported entry point of the XSL-T processor.
|
|
@@ -621,6 +764,16 @@ declare class Xslt {
|
|
|
621
764
|
* @protected
|
|
622
765
|
*/
|
|
623
766
|
protected xsltApplyTemplates(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
767
|
+
/**
|
|
768
|
+
* Implements `xsl:apply-imports`.
|
|
769
|
+
* Applies templates from imported stylesheets with the same match pattern and mode.
|
|
770
|
+
* This enables template overriding where a template in an importing stylesheet
|
|
771
|
+
* can call the overridden template from the imported stylesheet.
|
|
772
|
+
* @param context The Expression Context.
|
|
773
|
+
* @param template The apply-imports template node.
|
|
774
|
+
* @param output The output node.
|
|
775
|
+
*/
|
|
776
|
+
protected xsltApplyImports(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
624
777
|
/**
|
|
625
778
|
* Implements `xsl:attribute`.
|
|
626
779
|
* @param context The Expression Context.
|
|
@@ -658,6 +811,13 @@ declare class Xslt {
|
|
|
658
811
|
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
659
812
|
*/
|
|
660
813
|
protected xsltComment(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
814
|
+
/**
|
|
815
|
+
* Implements `xsl:processing-instruction`.
|
|
816
|
+
* @param context The Expression Context.
|
|
817
|
+
* @param template The template.
|
|
818
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
819
|
+
*/
|
|
820
|
+
protected xsltProcessingInstruction(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
661
821
|
/**
|
|
662
822
|
* Implements `xsl:copy-of` for node-set values of the select
|
|
663
823
|
* expression. Recurses down the source node tree, which is part of
|
|
@@ -957,6 +1117,58 @@ declare class Xslt {
|
|
|
957
1117
|
* @param template The template node.
|
|
958
1118
|
*/
|
|
959
1119
|
protected xsltWithParam(context: ExprContext, template: XNode): Promise<void>;
|
|
1120
|
+
/**
|
|
1121
|
+
* Recursively map all template nodes in a stylesheet to their metadata.
|
|
1122
|
+
* Used to track which stylesheet each template comes from for apply-imports.
|
|
1123
|
+
* @param stylesheetElement The stylesheet or transform element (or any parent element).
|
|
1124
|
+
* @param metadata The metadata for this stylesheet.
|
|
1125
|
+
*/
|
|
1126
|
+
private mapTemplatesFromStylesheet;
|
|
1127
|
+
/**
|
|
1128
|
+
* Collect all attribute set definitions from the stylesheet.
|
|
1129
|
+
* Called at stylesheet initialization time.
|
|
1130
|
+
* @param stylesheetElement The stylesheet or transform element.
|
|
1131
|
+
*/
|
|
1132
|
+
private collectAttributeSets;
|
|
1133
|
+
/**
|
|
1134
|
+
* Apply one or more attribute sets to an element.
|
|
1135
|
+
* Parses space-separated attribute set names and applies them.
|
|
1136
|
+
* @param context The Expression Context.
|
|
1137
|
+
* @param element The element to apply attributes to.
|
|
1138
|
+
* @param setNames Space-separated attribute set names.
|
|
1139
|
+
*/
|
|
1140
|
+
protected applyAttributeSets(context: ExprContext, element: XNode, setNames: string): Promise<void>;
|
|
1141
|
+
/**
|
|
1142
|
+
* Apply a single attribute set to an element.
|
|
1143
|
+
* Handles recursive attribute sets with cycle detection.
|
|
1144
|
+
* @param context The Expression Context.
|
|
1145
|
+
* @param element The element to apply attributes to.
|
|
1146
|
+
* @param setName The name of the attribute set to apply.
|
|
1147
|
+
* @param processedSets Set of already-processed attribute set names (for cycle detection).
|
|
1148
|
+
*/
|
|
1149
|
+
private applyAttributeSet;
|
|
1150
|
+
/**
|
|
1151
|
+
* Test if an element is a supported extension.
|
|
1152
|
+
* Returns false for unrecognized elements in non-XSLT namespaces.
|
|
1153
|
+
* @param node The element to test.
|
|
1154
|
+
* @returns True if the element is supported, false if it's an unrecognized extension.
|
|
1155
|
+
*/
|
|
1156
|
+
protected isExtensionElementSupported(node: XNode): boolean;
|
|
1157
|
+
/**
|
|
1158
|
+
* Get the fallback element from an extension element if it exists.
|
|
1159
|
+
* Searches for the first direct xsl:fallback child.
|
|
1160
|
+
* @param node The extension element.
|
|
1161
|
+
* @returns The fallback element, or null if not found.
|
|
1162
|
+
*/
|
|
1163
|
+
protected getFallbackElement(node: XNode): XNode | null;
|
|
1164
|
+
/**
|
|
1165
|
+
* Process an extension element with fallback support.
|
|
1166
|
+
* If a fallback is defined, executes it; otherwise treats element as literal.
|
|
1167
|
+
* @param context The Expression Context.
|
|
1168
|
+
* @param element The extension element.
|
|
1169
|
+
* @param output The output node.
|
|
1170
|
+
*/
|
|
1171
|
+
protected xsltExtensionElement(context: ExprContext, element: XNode, output?: XNode): Promise<void>;
|
|
960
1172
|
/**
|
|
961
1173
|
* Test if the given element is an XSLT element, optionally the one with the given name.
|
|
962
1174
|
* @param {XNode} element The element.
|
package/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ declare class XDocument extends XNode {
|
|
|
73
73
|
createComment(data: any): XNode;
|
|
74
74
|
createCDATASection(data: any): XNode;
|
|
75
75
|
createDTDSection(data: any): XNode;
|
|
76
|
+
createProcessingInstruction(target: string, data: any): XNode;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
/**
|
|
@@ -169,6 +170,21 @@ type XPathFunctions = Record<string, XPathFunction>;
|
|
|
169
170
|
* Type for namespace bindings (prefix -> namespace URI).
|
|
170
171
|
*/
|
|
171
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>;
|
|
172
188
|
/**
|
|
173
189
|
* The evaluation context for XPath expressions.
|
|
174
190
|
*
|
|
@@ -177,6 +193,7 @@ type XPathNamespaces = Record<string, string>;
|
|
|
177
193
|
* - Position information for predicates
|
|
178
194
|
* - Variable bindings
|
|
179
195
|
* - Custom function definitions
|
|
196
|
+
* - Dynamic properties like current dateTime, available documents, etc.
|
|
180
197
|
*/
|
|
181
198
|
interface XPathContext {
|
|
182
199
|
/**
|
|
@@ -219,11 +236,85 @@ interface XPathContext {
|
|
|
219
236
|
* Used by functions like json-to-xml() which are only available in XSLT 3.0+
|
|
220
237
|
*/
|
|
221
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;
|
|
222
310
|
}
|
|
223
311
|
/**
|
|
224
312
|
* Result types that can be returned from XPath evaluation.
|
|
313
|
+
*
|
|
314
|
+
* XPath 1.0: node-set, string, number, boolean
|
|
315
|
+
* XPath 2.0+: sequences (which subsume node-sets), atomic values, functions
|
|
225
316
|
*/
|
|
226
|
-
type XPathResult = XPathNode[] | string | number | boolean;
|
|
317
|
+
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null | Function;
|
|
227
318
|
|
|
228
319
|
declare abstract class XPathExpression {
|
|
229
320
|
abstract evaluate(context: XPathContext): XPathResult;
|
|
@@ -314,6 +405,25 @@ declare class ExprContext {
|
|
|
314
405
|
knownNamespaces: {
|
|
315
406
|
[alias: string]: string;
|
|
316
407
|
};
|
|
408
|
+
/**
|
|
409
|
+
* Custom system properties for system-property() function.
|
|
410
|
+
* Overrides the default properties (xsl:version, xsl:vendor, xsl:vendor-url).
|
|
411
|
+
*/
|
|
412
|
+
systemProperties?: {
|
|
413
|
+
[name: string]: string;
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Document loader function for the document() function.
|
|
417
|
+
* Takes a URI and returns an XNode document, or null if loading fails.
|
|
418
|
+
*/
|
|
419
|
+
documentLoader?: (uri: string) => XNode | null;
|
|
420
|
+
/**
|
|
421
|
+
* Unparsed entity URIs for the unparsed-entity-uri() function.
|
|
422
|
+
* Maps entity names to their URIs (from DTD declarations).
|
|
423
|
+
*/
|
|
424
|
+
unparsedEntities?: {
|
|
425
|
+
[name: string]: string;
|
|
426
|
+
};
|
|
317
427
|
caseInsensitive: any;
|
|
318
428
|
ignoreAttributesWithoutValue: any;
|
|
319
429
|
returnOnFirstMatch: any;
|
|
@@ -416,6 +526,8 @@ declare class NodeConverter {
|
|
|
416
526
|
private convertVariables;
|
|
417
527
|
/**
|
|
418
528
|
* Create custom functions for XPath context (like key(), document(), etc.).
|
|
529
|
+
* Note: Custom functions receive the XPathContext as their first argument,
|
|
530
|
+
* followed by the evaluated function arguments.
|
|
419
531
|
*/
|
|
420
532
|
private createCustomFunctions;
|
|
421
533
|
/**
|
|
@@ -598,6 +710,37 @@ declare class Xslt {
|
|
|
598
710
|
* Maps stylesheet namespace prefixes to result namespace prefixes.
|
|
599
711
|
*/
|
|
600
712
|
namespaceAliases: Map<string, string>;
|
|
713
|
+
/**
|
|
714
|
+
* Set of supported extension element namespaces.
|
|
715
|
+
* Processors can register custom extension namespaces here.
|
|
716
|
+
* Currently only XSLT namespace is auto-registered.
|
|
717
|
+
*/
|
|
718
|
+
supportedExtensions: Set<string>;
|
|
719
|
+
/**
|
|
720
|
+
* Map of attribute sets defined in the stylesheet.
|
|
721
|
+
* Keys are attribute set names, values are arrays of xsl:attribute nodes.
|
|
722
|
+
*/
|
|
723
|
+
attributeSets: Map<string, XNode[]>;
|
|
724
|
+
/**
|
|
725
|
+
* Stack of stylesheet metadata for tracking import hierarchy.
|
|
726
|
+
* Used by apply-imports to find templates from imported stylesheets.
|
|
727
|
+
*/
|
|
728
|
+
private styleSheetStack;
|
|
729
|
+
/**
|
|
730
|
+
* Map of imported stylesheet HREFs to their parsed XNodes.
|
|
731
|
+
* Prevents duplicate imports and allows precedence tracking.
|
|
732
|
+
*/
|
|
733
|
+
private importedStylesheets;
|
|
734
|
+
/**
|
|
735
|
+
* Map templates to the stylesheet they came from.
|
|
736
|
+
* Enables apply-imports to find templates by import precedence.
|
|
737
|
+
*/
|
|
738
|
+
private templateSourceMap;
|
|
739
|
+
/**
|
|
740
|
+
* Stack of currently executing templates with their metadata.
|
|
741
|
+
* Used by apply-imports to determine which template called it.
|
|
742
|
+
*/
|
|
743
|
+
private currentTemplateStack;
|
|
601
744
|
constructor(options?: Partial<XsltOptions>);
|
|
602
745
|
/**
|
|
603
746
|
* The exported entry point of the XSL-T processor.
|
|
@@ -621,6 +764,16 @@ declare class Xslt {
|
|
|
621
764
|
* @protected
|
|
622
765
|
*/
|
|
623
766
|
protected xsltApplyTemplates(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
767
|
+
/**
|
|
768
|
+
* Implements `xsl:apply-imports`.
|
|
769
|
+
* Applies templates from imported stylesheets with the same match pattern and mode.
|
|
770
|
+
* This enables template overriding where a template in an importing stylesheet
|
|
771
|
+
* can call the overridden template from the imported stylesheet.
|
|
772
|
+
* @param context The Expression Context.
|
|
773
|
+
* @param template The apply-imports template node.
|
|
774
|
+
* @param output The output node.
|
|
775
|
+
*/
|
|
776
|
+
protected xsltApplyImports(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
624
777
|
/**
|
|
625
778
|
* Implements `xsl:attribute`.
|
|
626
779
|
* @param context The Expression Context.
|
|
@@ -658,6 +811,13 @@ declare class Xslt {
|
|
|
658
811
|
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
659
812
|
*/
|
|
660
813
|
protected xsltComment(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
814
|
+
/**
|
|
815
|
+
* Implements `xsl:processing-instruction`.
|
|
816
|
+
* @param context The Expression Context.
|
|
817
|
+
* @param template The template.
|
|
818
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
819
|
+
*/
|
|
820
|
+
protected xsltProcessingInstruction(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
661
821
|
/**
|
|
662
822
|
* Implements `xsl:copy-of` for node-set values of the select
|
|
663
823
|
* expression. Recurses down the source node tree, which is part of
|
|
@@ -957,6 +1117,58 @@ declare class Xslt {
|
|
|
957
1117
|
* @param template The template node.
|
|
958
1118
|
*/
|
|
959
1119
|
protected xsltWithParam(context: ExprContext, template: XNode): Promise<void>;
|
|
1120
|
+
/**
|
|
1121
|
+
* Recursively map all template nodes in a stylesheet to their metadata.
|
|
1122
|
+
* Used to track which stylesheet each template comes from for apply-imports.
|
|
1123
|
+
* @param stylesheetElement The stylesheet or transform element (or any parent element).
|
|
1124
|
+
* @param metadata The metadata for this stylesheet.
|
|
1125
|
+
*/
|
|
1126
|
+
private mapTemplatesFromStylesheet;
|
|
1127
|
+
/**
|
|
1128
|
+
* Collect all attribute set definitions from the stylesheet.
|
|
1129
|
+
* Called at stylesheet initialization time.
|
|
1130
|
+
* @param stylesheetElement The stylesheet or transform element.
|
|
1131
|
+
*/
|
|
1132
|
+
private collectAttributeSets;
|
|
1133
|
+
/**
|
|
1134
|
+
* Apply one or more attribute sets to an element.
|
|
1135
|
+
* Parses space-separated attribute set names and applies them.
|
|
1136
|
+
* @param context The Expression Context.
|
|
1137
|
+
* @param element The element to apply attributes to.
|
|
1138
|
+
* @param setNames Space-separated attribute set names.
|
|
1139
|
+
*/
|
|
1140
|
+
protected applyAttributeSets(context: ExprContext, element: XNode, setNames: string): Promise<void>;
|
|
1141
|
+
/**
|
|
1142
|
+
* Apply a single attribute set to an element.
|
|
1143
|
+
* Handles recursive attribute sets with cycle detection.
|
|
1144
|
+
* @param context The Expression Context.
|
|
1145
|
+
* @param element The element to apply attributes to.
|
|
1146
|
+
* @param setName The name of the attribute set to apply.
|
|
1147
|
+
* @param processedSets Set of already-processed attribute set names (for cycle detection).
|
|
1148
|
+
*/
|
|
1149
|
+
private applyAttributeSet;
|
|
1150
|
+
/**
|
|
1151
|
+
* Test if an element is a supported extension.
|
|
1152
|
+
* Returns false for unrecognized elements in non-XSLT namespaces.
|
|
1153
|
+
* @param node The element to test.
|
|
1154
|
+
* @returns True if the element is supported, false if it's an unrecognized extension.
|
|
1155
|
+
*/
|
|
1156
|
+
protected isExtensionElementSupported(node: XNode): boolean;
|
|
1157
|
+
/**
|
|
1158
|
+
* Get the fallback element from an extension element if it exists.
|
|
1159
|
+
* Searches for the first direct xsl:fallback child.
|
|
1160
|
+
* @param node The extension element.
|
|
1161
|
+
* @returns The fallback element, or null if not found.
|
|
1162
|
+
*/
|
|
1163
|
+
protected getFallbackElement(node: XNode): XNode | null;
|
|
1164
|
+
/**
|
|
1165
|
+
* Process an extension element with fallback support.
|
|
1166
|
+
* If a fallback is defined, executes it; otherwise treats element as literal.
|
|
1167
|
+
* @param context The Expression Context.
|
|
1168
|
+
* @param element The extension element.
|
|
1169
|
+
* @param output The output node.
|
|
1170
|
+
*/
|
|
1171
|
+
protected xsltExtensionElement(context: ExprContext, element: XNode, output?: XNode): Promise<void>;
|
|
960
1172
|
/**
|
|
961
1173
|
* Test if the given element is an XSLT element, optionally the one with the given name.
|
|
962
1174
|
* @param {XNode} element The element.
|