xslt-processor 4.6.1 → 4.8.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/README.md +28 -31
- package/index.d.mts +610 -250
- package/index.d.ts +610 -250
- package/index.js +12946 -6135
- package/index.js.map +1 -1
- package/index.mjs +13554 -6743
- package/index.mjs.map +1 -1
- package/package.json +12 -3
- package/umd/xslt-processor.global.js +6 -3
- package/umd/xslt-processor.global.js.map +1 -1
package/index.d.mts
CHANGED
|
@@ -132,6 +132,225 @@ declare class XmlParser {
|
|
|
132
132
|
private xmlStrictParse;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
type XsltParameter = {
|
|
136
|
+
name: string;
|
|
137
|
+
namespaceUri?: string;
|
|
138
|
+
value: any;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* According to https://www.w3schools.com/xml/ref_xsl_el_decimal-format.asp:
|
|
143
|
+
*
|
|
144
|
+
* @property {string} name: Optional. Specifies a name for this format.
|
|
145
|
+
* @property {string} decimalSeparator: Optional. Specifies the decimal point character. Default is ".".
|
|
146
|
+
* @property {string} groupingSeparator: Optional. Specifies the thousands separator character. Default is ",".
|
|
147
|
+
* @property {string} infinity: Optional. Specifies the string used to represent infinity. Default is "Infinity".
|
|
148
|
+
* @property {string} minusSign: Optional. Specifies the character to represent negative numbers. Default is "-".
|
|
149
|
+
* @property {string} naN: Optional. Specifies the string used when the value is not a number". Default is "NaN".
|
|
150
|
+
* @property {string} percent: Optional. Specifies the percentage sign character. Default is "%".
|
|
151
|
+
* @property {string} perMille: Optional. Specifies the per thousand sign character. Default is "‰".
|
|
152
|
+
* @property {string} zeroDigit: Optional. Specifies the digit zero character. Default is "0".
|
|
153
|
+
* @property {string} digit: Optional. Specifies the character used to indicate a place where a digit is required. Default is #.
|
|
154
|
+
* @property {string} patternSeparator: Optional. Specifies the character used to separate positive and negative subpatterns in a format pattern. Default is ";".
|
|
155
|
+
*/
|
|
156
|
+
type XsltDecimalFormatSettings = {
|
|
157
|
+
name?: string;
|
|
158
|
+
decimalSeparator: string;
|
|
159
|
+
groupingSeparator: string;
|
|
160
|
+
infinity: string;
|
|
161
|
+
minusSign: string;
|
|
162
|
+
naN: string;
|
|
163
|
+
percent: string;
|
|
164
|
+
perMille: string;
|
|
165
|
+
zeroDigit: string;
|
|
166
|
+
digit: string;
|
|
167
|
+
patternSeparator: string;
|
|
168
|
+
};
|
|
169
|
+
type XsltOptions = {
|
|
170
|
+
cData: boolean;
|
|
171
|
+
escape: boolean;
|
|
172
|
+
selfClosingTags: boolean;
|
|
173
|
+
outputMethod?: 'xml' | 'html' | 'text' | 'xhtml' | 'json' | 'adaptive';
|
|
174
|
+
parameters?: XsltParameter[];
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
interface NodeValue {
|
|
178
|
+
type: string;
|
|
179
|
+
stringValue(): string;
|
|
180
|
+
booleanValue(): boolean;
|
|
181
|
+
numberValue(): number;
|
|
182
|
+
nodeSetValue(): XNode[];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* XPath expression evaluation context. An XPath context consists of a
|
|
187
|
+
* DOM node, a list of DOM nodes that contains this node, a number
|
|
188
|
+
* that represents the position of the single node in the list, and a
|
|
189
|
+
* current set of variable bindings. (See XPath spec.)
|
|
190
|
+
*
|
|
191
|
+
* setVariable(name, expr) -- binds given XPath expression to the
|
|
192
|
+
* name.
|
|
193
|
+
*
|
|
194
|
+
* getVariable(name) -- what the name says.
|
|
195
|
+
*
|
|
196
|
+
* setNode(position) -- sets the context to the node at the given
|
|
197
|
+
* position. Needed to implement scoping rules for variables in
|
|
198
|
+
* XPath. (A variable is visible to all subsequent siblings, not
|
|
199
|
+
* only to its children.)
|
|
200
|
+
*
|
|
201
|
+
* set/isCaseInsensitive -- specifies whether node name tests should
|
|
202
|
+
* be case sensitive. If you're executing xpaths against a regular
|
|
203
|
+
* HTML DOM, you probably don't want case-sensitivity, because
|
|
204
|
+
* browsers tend to disagree about whether elements & attributes
|
|
205
|
+
* should be upper/lower case. If you're running xpaths in an
|
|
206
|
+
* XSLT instance, you probably DO want case sensitivity, as per the
|
|
207
|
+
* XSL spec.
|
|
208
|
+
*
|
|
209
|
+
* set/isReturnOnFirstMatch -- whether XPath evaluation should quit as soon
|
|
210
|
+
* as a result is found. This is an optimization that might make sense if you
|
|
211
|
+
* only care about the first result.
|
|
212
|
+
*
|
|
213
|
+
* set/isIgnoreNonElementNodesForNTA -- whether to ignore non-element nodes
|
|
214
|
+
* when evaluating the "node()" any node test. While technically this is
|
|
215
|
+
* contrary to the XPath spec, practically it can enhance performance
|
|
216
|
+
* significantly, and makes sense if you a) use "node()" when you mean "*",
|
|
217
|
+
* and b) use "//" when you mean "/descendant::* /".
|
|
218
|
+
*/
|
|
219
|
+
declare class ExprContext {
|
|
220
|
+
position: number;
|
|
221
|
+
nodeList: XNode[];
|
|
222
|
+
xsltVersion: '1.0' | '2.0' | '3.0';
|
|
223
|
+
variables: {
|
|
224
|
+
[name: string]: NodeValue;
|
|
225
|
+
};
|
|
226
|
+
keys: {
|
|
227
|
+
[name: string]: {
|
|
228
|
+
[key: string]: NodeValue;
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
knownNamespaces: {
|
|
232
|
+
[alias: string]: string;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Custom system properties for system-property() function.
|
|
236
|
+
* Overrides the default properties (xsl:version, xsl:vendor, xsl:vendor-url).
|
|
237
|
+
*/
|
|
238
|
+
systemProperties?: {
|
|
239
|
+
[name: string]: string;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Document loader function for the document() function.
|
|
243
|
+
* Takes a URI and returns an XNode document, or null if loading fails.
|
|
244
|
+
*/
|
|
245
|
+
documentLoader?: (uri: string) => XNode | null;
|
|
246
|
+
/**
|
|
247
|
+
* Unparsed entity URIs for the unparsed-entity-uri() function.
|
|
248
|
+
* Maps entity names to their URIs (from DTD declarations).
|
|
249
|
+
*/
|
|
250
|
+
unparsedEntities?: {
|
|
251
|
+
[name: string]: string;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Warning callback for non-fatal XPath/XSLT warnings.
|
|
255
|
+
*/
|
|
256
|
+
warningsCallback?: (...args: any[]) => void;
|
|
257
|
+
caseInsensitive: any;
|
|
258
|
+
ignoreAttributesWithoutValue: any;
|
|
259
|
+
returnOnFirstMatch: any;
|
|
260
|
+
ignoreNonElementNodesForNTA: any;
|
|
261
|
+
parent: ExprContext;
|
|
262
|
+
root: XNode;
|
|
263
|
+
decimalFormatSettings: XsltDecimalFormatSettings;
|
|
264
|
+
inApplyTemplates: boolean;
|
|
265
|
+
baseTemplateMatched: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Regex groups from xsl:analyze-string for regex-group() function.
|
|
268
|
+
* Index 0 is the full match, 1+ are captured groups.
|
|
269
|
+
*/
|
|
270
|
+
regexGroups?: string[];
|
|
271
|
+
/**
|
|
272
|
+
* Current group from xsl:for-each-group for current-group() function.
|
|
273
|
+
* Contains the nodes/items in the current group being processed.
|
|
274
|
+
*/
|
|
275
|
+
currentGroup?: XNode[];
|
|
276
|
+
/**
|
|
277
|
+
* Current grouping key from xsl:for-each-group for current-grouping-key() function.
|
|
278
|
+
* Contains the key value of the current group being processed.
|
|
279
|
+
*/
|
|
280
|
+
currentGroupingKey?: any;
|
|
281
|
+
/**
|
|
282
|
+
* User-defined XSLT functions from xsl:function declarations.
|
|
283
|
+
* Maps QName (namespace:localname) to function definition info.
|
|
284
|
+
*/
|
|
285
|
+
userDefinedFunctions?: Map<string, {
|
|
286
|
+
functionDef: XNode;
|
|
287
|
+
executor: (context: ExprContext, functionDef: XNode, args: any[]) => any;
|
|
288
|
+
}>;
|
|
289
|
+
/**
|
|
290
|
+
* Constructor -- gets the node, its position, the node set it
|
|
291
|
+
* belongs to, and a parent context as arguments. The parent context
|
|
292
|
+
* is used to implement scoping rules for variables: if a variable
|
|
293
|
+
* is not found in the current context, it is looked for in the
|
|
294
|
+
* parent context, recursively. Except for node, all arguments have
|
|
295
|
+
* default values: default position is 0, default node set is the
|
|
296
|
+
* set that contains only the node, and the default parent is null.
|
|
297
|
+
*
|
|
298
|
+
* Notice that position starts at 0 at the outside interface;
|
|
299
|
+
* inside XPath expressions this shows up as position()=1.
|
|
300
|
+
* @param nodeList TODO
|
|
301
|
+
* @param opt_position TODO
|
|
302
|
+
* @param opt_parent TODO
|
|
303
|
+
* @param opt_caseInsensitive TODO
|
|
304
|
+
* @param opt_ignoreAttributesWithoutValue TODO
|
|
305
|
+
* @param opt_returnOnFirstMatch TODO
|
|
306
|
+
* @param opt_ignoreNonElementNodesForNTA TODO
|
|
307
|
+
*/
|
|
308
|
+
constructor(nodeList: XNode[], xsltVersion?: '1.0' | '2.0' | '3.0', opt_position?: number, opt_decimalFormatSettings?: XsltDecimalFormatSettings, opt_variables?: {
|
|
309
|
+
[name: string]: any;
|
|
310
|
+
}, opt_knownNamespaces?: {
|
|
311
|
+
[alias: string]: string;
|
|
312
|
+
}, opt_parent?: ExprContext, opt_caseInsensitive?: any, opt_ignoreAttributesWithoutValue?: any, opt_returnOnFirstMatch?: any, opt_ignoreNonElementNodesForNTA?: any, opt_warningsCallback?: (...args: any[]) => void);
|
|
313
|
+
/**
|
|
314
|
+
* clone() -- creates a new context with the current context as
|
|
315
|
+
* parent. If passed as argument to clone(), the new context has a
|
|
316
|
+
* different node, position, or node set. What is not passed is
|
|
317
|
+
* inherited from the cloned context.
|
|
318
|
+
* @param opt_nodeList TODO
|
|
319
|
+
* @param opt_position TODO
|
|
320
|
+
* @returns TODO
|
|
321
|
+
*/
|
|
322
|
+
clone(opt_nodeList?: XNode[], opt_position?: number): ExprContext;
|
|
323
|
+
setVariable(name?: string, value?: NodeValue | string): void;
|
|
324
|
+
getVariable(name: string): NodeValue;
|
|
325
|
+
/**
|
|
326
|
+
* Gets a regex group from xsl:analyze-string context.
|
|
327
|
+
* Searches up the parent chain for regexGroups.
|
|
328
|
+
* @param index Group index (0 = full match, 1+ = captured groups)
|
|
329
|
+
* @returns The group value or empty string if not found
|
|
330
|
+
*/
|
|
331
|
+
getRegexGroup(index: number): string;
|
|
332
|
+
setNode(position: number): void;
|
|
333
|
+
contextSize(): number;
|
|
334
|
+
isCaseInsensitive(): any;
|
|
335
|
+
setCaseInsensitive(caseInsensitive: any): any;
|
|
336
|
+
isIgnoreAttributesWithoutValue(): any;
|
|
337
|
+
setIgnoreAttributesWithoutValue(ignore: any): any;
|
|
338
|
+
isReturnOnFirstMatch(): any;
|
|
339
|
+
setReturnOnFirstMatch(returnOnFirstMatch: any): any;
|
|
340
|
+
isIgnoreNonElementNodesForNTA(): any;
|
|
341
|
+
setIgnoreNonElementNodesForNTA(ignoreNonElementNodesForNTA: any): any;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* XPath version support and configuration.
|
|
346
|
+
*
|
|
347
|
+
* This module defines version-specific behavior and prepares for future XPath 2.0/3.0 support.
|
|
348
|
+
*/
|
|
349
|
+
/**
|
|
350
|
+
* Supported XPath specification versions.
|
|
351
|
+
*/
|
|
352
|
+
type XPathVersion = '1.0' | '2.0' | '3.0' | '3.1';
|
|
353
|
+
|
|
135
354
|
/**
|
|
136
355
|
* Represents a DOM-like node interface for XPath evaluation.
|
|
137
356
|
* This is compatible with browser DOM nodes and can be extended for other implementations.
|
|
@@ -280,233 +499,57 @@ interface XPathContext {
|
|
|
280
499
|
/**
|
|
281
500
|
* Current dateTime in the dynamic context (XPath 2.0+).
|
|
282
501
|
* 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;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
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
|
|
327
|
-
*/
|
|
328
|
-
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null | XPathFunctionItem;
|
|
329
|
-
|
|
330
|
-
declare abstract class XPathExpression {
|
|
331
|
-
abstract evaluate(context: XPathContext): XPathResult;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* According to https://www.w3schools.com/xml/ref_xsl_el_decimal-format.asp:
|
|
336
|
-
*
|
|
337
|
-
* @property {string} name: Optional. Specifies a name for this format.
|
|
338
|
-
* @property {string} decimalSeparator: Optional. Specifies the decimal point character. Default is ".".
|
|
339
|
-
* @property {string} groupingSeparator: Optional. Specifies the thousands separator character. Default is ",".
|
|
340
|
-
* @property {string} infinity: Optional. Specifies the string used to represent infinity. Default is "Infinity".
|
|
341
|
-
* @property {string} minusSign: Optional. Specifies the character to represent negative numbers. Default is "-".
|
|
342
|
-
* @property {string} naN: Optional. Specifies the string used when the value is not a number". Default is "NaN".
|
|
343
|
-
* @property {string} percent: Optional. Specifies the percentage sign character. Default is "%".
|
|
344
|
-
* @property {string} perMille: Optional. Specifies the per thousand sign character. Default is "‰".
|
|
345
|
-
* @property {string} zeroDigit: Optional. Specifies the digit zero character. Default is "0".
|
|
346
|
-
* @property {string} digit: Optional. Specifies the character used to indicate a place where a digit is required. Default is #.
|
|
347
|
-
* @property {string} patternSeparator: Optional. Specifies the character used to separate positive and negative subpatterns in a format pattern. Default is ";".
|
|
348
|
-
*/
|
|
349
|
-
type XsltDecimalFormatSettings = {
|
|
350
|
-
name?: string;
|
|
351
|
-
decimalSeparator: string;
|
|
352
|
-
groupingSeparator: string;
|
|
353
|
-
infinity: string;
|
|
354
|
-
minusSign: string;
|
|
355
|
-
naN: string;
|
|
356
|
-
percent: string;
|
|
357
|
-
perMille: string;
|
|
358
|
-
zeroDigit: string;
|
|
359
|
-
digit: string;
|
|
360
|
-
patternSeparator: string;
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
interface NodeValue {
|
|
364
|
-
stringValue(): string;
|
|
365
|
-
booleanValue(): boolean;
|
|
366
|
-
numberValue(): number;
|
|
367
|
-
nodeSetValue(): XNode[];
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* XPath expression evaluation context. An XPath context consists of a
|
|
372
|
-
* DOM node, a list of DOM nodes that contains this node, a number
|
|
373
|
-
* that represents the position of the single node in the list, and a
|
|
374
|
-
* current set of variable bindings. (See XPath spec.)
|
|
375
|
-
*
|
|
376
|
-
* setVariable(name, expr) -- binds given XPath expression to the
|
|
377
|
-
* name.
|
|
378
|
-
*
|
|
379
|
-
* getVariable(name) -- what the name says.
|
|
380
|
-
*
|
|
381
|
-
* setNode(position) -- sets the context to the node at the given
|
|
382
|
-
* position. Needed to implement scoping rules for variables in
|
|
383
|
-
* XPath. (A variable is visible to all subsequent siblings, not
|
|
384
|
-
* only to its children.)
|
|
385
|
-
*
|
|
386
|
-
* set/isCaseInsensitive -- specifies whether node name tests should
|
|
387
|
-
* be case sensitive. If you're executing xpaths against a regular
|
|
388
|
-
* HTML DOM, you probably don't want case-sensitivity, because
|
|
389
|
-
* browsers tend to disagree about whether elements & attributes
|
|
390
|
-
* should be upper/lower case. If you're running xpaths in an
|
|
391
|
-
* XSLT instance, you probably DO want case sensitivity, as per the
|
|
392
|
-
* XSL spec.
|
|
393
|
-
*
|
|
394
|
-
* set/isReturnOnFirstMatch -- whether XPath evaluation should quit as soon
|
|
395
|
-
* as a result is found. This is an optimization that might make sense if you
|
|
396
|
-
* only care about the first result.
|
|
397
|
-
*
|
|
398
|
-
* set/isIgnoreNonElementNodesForNTA -- whether to ignore non-element nodes
|
|
399
|
-
* when evaluating the "node()" any node test. While technically this is
|
|
400
|
-
* contrary to the XPath spec, practically it can enhance performance
|
|
401
|
-
* significantly, and makes sense if you a) use "node()" when you mean "*",
|
|
402
|
-
* and b) use "//" when you mean "/descendant::* /".
|
|
403
|
-
*/
|
|
404
|
-
declare class ExprContext {
|
|
405
|
-
position: number;
|
|
406
|
-
nodeList: XNode[];
|
|
407
|
-
xsltVersion: '1.0' | '2.0' | '3.0';
|
|
408
|
-
variables: {
|
|
409
|
-
[name: string]: NodeValue;
|
|
410
|
-
};
|
|
411
|
-
keys: {
|
|
412
|
-
[name: string]: {
|
|
413
|
-
[key: string]: NodeValue;
|
|
414
|
-
};
|
|
415
|
-
};
|
|
416
|
-
knownNamespaces: {
|
|
417
|
-
[alias: string]: string;
|
|
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
|
-
};
|
|
438
|
-
caseInsensitive: any;
|
|
439
|
-
ignoreAttributesWithoutValue: any;
|
|
440
|
-
returnOnFirstMatch: any;
|
|
441
|
-
ignoreNonElementNodesForNTA: any;
|
|
442
|
-
parent: ExprContext;
|
|
443
|
-
root: XNode;
|
|
444
|
-
decimalFormatSettings: XsltDecimalFormatSettings;
|
|
445
|
-
inApplyTemplates: boolean;
|
|
446
|
-
baseTemplateMatched: boolean;
|
|
447
|
-
/**
|
|
448
|
-
* Constructor -- gets the node, its position, the node set it
|
|
449
|
-
* belongs to, and a parent context as arguments. The parent context
|
|
450
|
-
* is used to implement scoping rules for variables: if a variable
|
|
451
|
-
* is not found in the current context, it is looked for in the
|
|
452
|
-
* parent context, recursively. Except for node, all arguments have
|
|
453
|
-
* default values: default position is 0, default node set is the
|
|
454
|
-
* set that contains only the node, and the default parent is null.
|
|
455
|
-
*
|
|
456
|
-
* Notice that position starts at 0 at the outside interface;
|
|
457
|
-
* inside XPath expressions this shows up as position()=1.
|
|
458
|
-
* @param nodeList TODO
|
|
459
|
-
* @param opt_position TODO
|
|
460
|
-
* @param opt_parent TODO
|
|
461
|
-
* @param opt_caseInsensitive TODO
|
|
462
|
-
* @param opt_ignoreAttributesWithoutValue TODO
|
|
463
|
-
* @param opt_returnOnFirstMatch TODO
|
|
464
|
-
* @param opt_ignoreNonElementNodesForNTA TODO
|
|
502
|
+
* If not provided, defaults to system time when accessed.
|
|
465
503
|
*/
|
|
466
|
-
|
|
467
|
-
[name: string]: any;
|
|
468
|
-
}, opt_knownNamespaces?: {
|
|
469
|
-
[alias: string]: string;
|
|
470
|
-
}, opt_parent?: ExprContext, opt_caseInsensitive?: any, opt_ignoreAttributesWithoutValue?: any, opt_returnOnFirstMatch?: any, opt_ignoreNonElementNodesForNTA?: any);
|
|
504
|
+
currentDateTime?: Date;
|
|
471
505
|
/**
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
* inherited from the cloned context.
|
|
476
|
-
* @param opt_nodeList TODO
|
|
477
|
-
* @param opt_position TODO
|
|
478
|
-
* @returns TODO
|
|
506
|
+
* Available documents mapping for fn:doc() function (XPath 2.0+).
|
|
507
|
+
* Maps document URIs to their root document nodes.
|
|
508
|
+
* Example: { "http://example.com/data.xml": rootNode }
|
|
479
509
|
*/
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
510
|
+
availableDocuments?: XPathDocuments;
|
|
511
|
+
/**
|
|
512
|
+
* Available collections mapping for fn:collection() function (XPath 2.0+).
|
|
513
|
+
* Maps collection URIs to sequences of nodes.
|
|
514
|
+
* Example: { "http://example.com/collection": [node1, node2, ...] }
|
|
515
|
+
*/
|
|
516
|
+
availableCollections?: XPathCollections;
|
|
517
|
+
/**
|
|
518
|
+
* Default collection URI when fn:collection() is called without arguments (XPath 2.0+).
|
|
519
|
+
* If provided, fn:collection() returns availableCollections[defaultCollection].
|
|
520
|
+
*/
|
|
521
|
+
defaultCollection?: string;
|
|
522
|
+
/**
|
|
523
|
+
* Function implementations registry (XPath 2.0+).
|
|
524
|
+
* Maps QName function names to their implementations.
|
|
525
|
+
* Allows defining custom/XSLT functions at evaluation time.
|
|
526
|
+
* Format: "localName" or "prefix:localName"
|
|
527
|
+
*/
|
|
528
|
+
functionRegistry?: XPathFunctionRegistry;
|
|
493
529
|
}
|
|
494
|
-
|
|
495
530
|
/**
|
|
496
|
-
*
|
|
497
|
-
*
|
|
531
|
+
* Represents an XPath 3.0 function item.
|
|
532
|
+
* This is a simplified interface to avoid circular dependencies.
|
|
498
533
|
*/
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
534
|
+
interface XPathFunctionItem {
|
|
535
|
+
__isFunctionItem: true;
|
|
536
|
+
implementation: (...args: any[]) => any;
|
|
537
|
+
arity: number;
|
|
538
|
+
name?: string;
|
|
539
|
+
namespace?: string;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Result types that can be returned from XPath evaluation.
|
|
543
|
+
*
|
|
544
|
+
* XPath 1.0: node-set, string, number, boolean
|
|
545
|
+
* XPath 2.0+: sequences (which subsume node-sets), atomic values, functions
|
|
546
|
+
*/
|
|
547
|
+
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null | XPathFunctionItem;
|
|
548
|
+
|
|
549
|
+
declare abstract class XPathExpression {
|
|
550
|
+
abstract evaluate(context: XPathContext): XPathResult;
|
|
509
551
|
}
|
|
552
|
+
|
|
510
553
|
/**
|
|
511
554
|
* Handles conversion between ExprContext and XPathContext.
|
|
512
555
|
* Uses XNode directly as XPathNode-compatible objects to preserve node identity.
|
|
@@ -560,22 +603,42 @@ declare class NodeConverter {
|
|
|
560
603
|
*/
|
|
561
604
|
clearCache(): void;
|
|
562
605
|
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Expression wrapper that provides backward-compatible interface.
|
|
609
|
+
* Wraps new XPath expressions to work with old ExprContext.
|
|
610
|
+
*/
|
|
611
|
+
declare class Expression {
|
|
612
|
+
protected xpathExpression: XPathExpression;
|
|
613
|
+
protected nodeConverter: NodeConverter;
|
|
614
|
+
absolute?: boolean;
|
|
615
|
+
steps?: any[];
|
|
616
|
+
constructor(xpathExpression: XPathExpression, nodeConverter: NodeConverter);
|
|
617
|
+
/**
|
|
618
|
+
* Evaluate the expression in the given context.
|
|
619
|
+
*/
|
|
620
|
+
evaluate(context: ExprContext): NodeValue;
|
|
621
|
+
}
|
|
622
|
+
|
|
563
623
|
/**
|
|
564
624
|
* XPath class that uses the new lexer/parser implementation
|
|
565
625
|
* while maintaining API compatibility with the old implementation.
|
|
566
626
|
*/
|
|
567
627
|
declare class XPath {
|
|
568
|
-
private
|
|
569
|
-
private
|
|
628
|
+
private lexers;
|
|
629
|
+
private parsers;
|
|
570
630
|
private nodeConverter;
|
|
571
631
|
private parseCache;
|
|
572
632
|
constructor();
|
|
633
|
+
private getLexer;
|
|
634
|
+
private getParser;
|
|
573
635
|
/**
|
|
574
636
|
* Parse an XPath expression and return an Expression object.
|
|
575
637
|
* @param expression The XPath expression string.
|
|
576
638
|
* @param axis Optional axis override for relative paths.
|
|
639
|
+
* @param version Optional XPath version (defaults to 1.0).
|
|
577
640
|
*/
|
|
578
|
-
xPathParse(expression: string, axis?: string): Expression;
|
|
641
|
+
xPathParse(expression: string, axis?: string, version?: XPathVersion): Expression;
|
|
579
642
|
/**
|
|
580
643
|
* Parse and evaluate an XPath expression.
|
|
581
644
|
* @param select The XPath expression string.
|
|
@@ -656,42 +719,33 @@ declare class MatchResolver {
|
|
|
656
719
|
private relativeXsltMatch;
|
|
657
720
|
}
|
|
658
721
|
|
|
659
|
-
type XsltParameter = {
|
|
660
|
-
name: string;
|
|
661
|
-
namespaceUri?: string;
|
|
662
|
-
value: any;
|
|
663
|
-
};
|
|
664
|
-
|
|
665
|
-
type XsltOptions = {
|
|
666
|
-
cData: boolean;
|
|
667
|
-
escape: boolean;
|
|
668
|
-
selfClosingTags: boolean;
|
|
669
|
-
outputMethod?: 'xml' | 'html' | 'text' | 'xhtml' | 'json' | 'adaptive';
|
|
670
|
-
parameters?: XsltParameter[];
|
|
671
|
-
};
|
|
672
|
-
|
|
673
722
|
/**
|
|
674
|
-
* The main class for XSL-T processing.
|
|
675
|
-
* complete; some xsl element are left out.
|
|
723
|
+
* The main class for XSL-T processing.
|
|
676
724
|
*
|
|
677
725
|
* References:
|
|
678
726
|
*
|
|
679
|
-
* [XSLT] XSL
|
|
680
|
-
* <
|
|
727
|
+
* [XSLT 1.0] XSL Transformations (XSLT) Version 1.0
|
|
728
|
+
* <https://www.w3.org/TR/1999/REC-xslt-19991116>.
|
|
729
|
+
*
|
|
730
|
+
* [XSLT 2.0] XSL Transformations (XSLT) Version 2.0
|
|
731
|
+
* <https://www.w3.org/TR/xslt20/>.
|
|
732
|
+
*
|
|
733
|
+
* [XSLT 3.0] XSL Transformations (XSLT) Version 3.0
|
|
734
|
+
* <https://www.w3.org/TR/xslt-30/>.
|
|
681
735
|
*
|
|
682
736
|
* [ECMA] ECMAScript Language Specification
|
|
683
737
|
* <http://www.ecma-international.org/publications/standards/Ecma-262.htm>.
|
|
684
738
|
*
|
|
685
|
-
* The XSL processor API has one entry point
|
|
686
|
-
* `xsltProcess()`. It receives as arguments the
|
|
687
|
-
*
|
|
688
|
-
* the
|
|
739
|
+
* The XSL processor API has one entry point: the async function
|
|
740
|
+
* `xsltProcess()`. It receives as arguments the input XML document
|
|
741
|
+
* and the XSL-T stylesheet document (both as `XDocument` instances),
|
|
742
|
+
* and returns the transformed output as a string (XML, HTML, JSON,
|
|
743
|
+
* or plain text depending on the output method).
|
|
689
744
|
*
|
|
690
|
-
* NOTE:
|
|
691
|
-
* defined as operation on text documents, not as operation on DOM
|
|
692
|
-
* trees.
|
|
693
|
-
*
|
|
694
|
-
* by an XML parser and serializer in order to be complete. Those two
|
|
745
|
+
* NOTE: Strictly speaking, XSL-T processing according to the specification
|
|
746
|
+
* is defined as operation on text documents, not as operation on DOM
|
|
747
|
+
* trees. This implementation operates on an internal DOM representation,
|
|
748
|
+
* complemented by an XML parser and serializer to be complete. Those two
|
|
695
749
|
* are found in the `dom` folder.
|
|
696
750
|
*/
|
|
697
751
|
declare class Xslt {
|
|
@@ -700,9 +754,12 @@ declare class Xslt {
|
|
|
700
754
|
matchResolver: MatchResolver;
|
|
701
755
|
options: XsltOptions;
|
|
702
756
|
decimalFormatSettings: XsltDecimalFormatSettings;
|
|
757
|
+
warningsCallback: (...args: any[]) => void;
|
|
703
758
|
outputDocument: XDocument;
|
|
704
759
|
outputMethod: 'xml' | 'html' | 'text' | 'name' | 'xhtml' | 'json' | 'adaptive';
|
|
705
760
|
outputOmitXmlDeclaration: string;
|
|
761
|
+
outputVersion: string;
|
|
762
|
+
itemSeparator: string;
|
|
706
763
|
version: string;
|
|
707
764
|
firstTemplateRan: boolean;
|
|
708
765
|
/**
|
|
@@ -741,6 +798,16 @@ declare class Xslt {
|
|
|
741
798
|
* Keys are attribute set names, values are arrays of xsl:attribute nodes.
|
|
742
799
|
*/
|
|
743
800
|
attributeSets: Map<string, XNode[]>;
|
|
801
|
+
/**
|
|
802
|
+
* Map of user-defined functions from xsl:function declarations.
|
|
803
|
+
* Keys are QNames (namespace:localname), values are the function definition nodes.
|
|
804
|
+
*/
|
|
805
|
+
userDefinedFunctions: Map<string, XNode>;
|
|
806
|
+
/**
|
|
807
|
+
* Result documents created by xsl:result-document.
|
|
808
|
+
* Keys are the href URIs, values are the serialized output strings.
|
|
809
|
+
*/
|
|
810
|
+
resultDocuments: Map<string, string>;
|
|
744
811
|
/**
|
|
745
812
|
* Stack of stylesheet metadata for tracking import hierarchy.
|
|
746
813
|
* Used by apply-imports to find templates from imported stylesheets.
|
|
@@ -761,6 +828,26 @@ declare class Xslt {
|
|
|
761
828
|
* Used by apply-imports to determine which template called it.
|
|
762
829
|
*/
|
|
763
830
|
private currentTemplateStack;
|
|
831
|
+
/**
|
|
832
|
+
* Package registry for XSLT 3.0 package system.
|
|
833
|
+
* Manages loaded packages and their components.
|
|
834
|
+
*/
|
|
835
|
+
private packageRegistry;
|
|
836
|
+
/**
|
|
837
|
+
* Current package being processed (for XSLT 3.0).
|
|
838
|
+
* null if processing a non-package stylesheet.
|
|
839
|
+
*/
|
|
840
|
+
private currentPackage;
|
|
841
|
+
/**
|
|
842
|
+
* Accumulator registry for XSLT 3.0 accumulators.
|
|
843
|
+
* Stores accumulator definitions and current state during processing.
|
|
844
|
+
*/
|
|
845
|
+
private accumulatorRegistry;
|
|
846
|
+
/**
|
|
847
|
+
* Streaming processor for XSLT 3.0 streaming processing.
|
|
848
|
+
* Encapsulates streaming context, copy management, and merge coordination.
|
|
849
|
+
*/
|
|
850
|
+
private streamingProcessor;
|
|
764
851
|
constructor(options?: Partial<XsltOptions>);
|
|
765
852
|
/**
|
|
766
853
|
* The exported entry point of the XSL-T processor.
|
|
@@ -799,6 +886,11 @@ declare class Xslt {
|
|
|
799
886
|
* @protected
|
|
800
887
|
*/
|
|
801
888
|
protected xsltApplyTemplates(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* Helper method to apply the built-in template for elements.
|
|
891
|
+
* The built-in template recursively applies templates to children.
|
|
892
|
+
*/
|
|
893
|
+
private applyBuiltInTemplate;
|
|
802
894
|
/**
|
|
803
895
|
* Implements `xsl:apply-imports`.
|
|
804
896
|
* Applies templates from imported stylesheets with the same match pattern and mode.
|
|
@@ -874,6 +966,32 @@ declare class Xslt {
|
|
|
874
966
|
* @param template The template.
|
|
875
967
|
*/
|
|
876
968
|
protected xsltElement(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
969
|
+
/**
|
|
970
|
+
* Implements `xsl:accumulator` (XSLT 3.0).
|
|
971
|
+
*
|
|
972
|
+
* Accumulators are a declarative way to compute values during template processing.
|
|
973
|
+
* They consist of rules that are applied as elements are processed.
|
|
974
|
+
*
|
|
975
|
+
* @param context The expression context
|
|
976
|
+
* @param template The xsl:accumulator element
|
|
977
|
+
*/
|
|
978
|
+
protected xsltAccumulator(context: ExprContext, template: XNode): void;
|
|
979
|
+
/**
|
|
980
|
+
* Evaluates all matching accumulator rules for a given node
|
|
981
|
+
* and updates the accumulator state
|
|
982
|
+
*
|
|
983
|
+
* @param context The expression context with current node
|
|
984
|
+
* @param node The current node being processed
|
|
985
|
+
*/
|
|
986
|
+
protected evaluateAccumulatorRules(context: ExprContext, node: XNode): void;
|
|
987
|
+
/**
|
|
988
|
+
* Retrieves the current value of an accumulator
|
|
989
|
+
* Used when accessing accumulators in templates via accumulator-after() or accumulator-before()
|
|
990
|
+
*
|
|
991
|
+
* @param accumulatorName The name of the accumulator
|
|
992
|
+
* @returns The current value of the accumulator, or null if not found
|
|
993
|
+
*/
|
|
994
|
+
protected getAccumulatorValue(accumulatorName: string): any;
|
|
877
995
|
/**
|
|
878
996
|
* Implements `xsl:for-each`.
|
|
879
997
|
* @param context The Expression Context.
|
|
@@ -881,6 +999,69 @@ declare class Xslt {
|
|
|
881
999
|
* @param output The output.
|
|
882
1000
|
*/
|
|
883
1001
|
protected xsltForEach(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1002
|
+
/**
|
|
1003
|
+
* Implements `xsl:for-each-group` (XSLT 2.0).
|
|
1004
|
+
*
|
|
1005
|
+
* Groups items from the select expression and processes each group.
|
|
1006
|
+
* Supports group-by and group-adjacent grouping methods.
|
|
1007
|
+
*
|
|
1008
|
+
* @param context The Expression Context.
|
|
1009
|
+
* @param template The template.
|
|
1010
|
+
* @param output The output.
|
|
1011
|
+
*/
|
|
1012
|
+
protected xsltForEachGroup(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1013
|
+
/**
|
|
1014
|
+
* Group items by a computed key value.
|
|
1015
|
+
* Items with the same key are placed in the same group.
|
|
1016
|
+
*/
|
|
1017
|
+
private groupByKey;
|
|
1018
|
+
/**
|
|
1019
|
+
* Group adjacent items with the same key.
|
|
1020
|
+
* A new group starts when the key changes.
|
|
1021
|
+
*/
|
|
1022
|
+
private groupAdjacent;
|
|
1023
|
+
/**
|
|
1024
|
+
* Convert an XSLT pattern to a self:: expression for matching against the current node.
|
|
1025
|
+
* For example, "h1" becomes "self::h1", "section[@type]" becomes "self::section[@type]".
|
|
1026
|
+
*/
|
|
1027
|
+
private patternToSelfExpression;
|
|
1028
|
+
/**
|
|
1029
|
+
* Group items starting with items that match a pattern.
|
|
1030
|
+
* A new group starts when an item matches the pattern.
|
|
1031
|
+
*/
|
|
1032
|
+
private groupStartingWith;
|
|
1033
|
+
/**
|
|
1034
|
+
* Group items ending with items that match a pattern.
|
|
1035
|
+
* A group ends when an item matches the pattern.
|
|
1036
|
+
*/
|
|
1037
|
+
private groupEndingWith;
|
|
1038
|
+
/**
|
|
1039
|
+
* Implements `xsl:iterate` (XSLT 3.0).
|
|
1040
|
+
*
|
|
1041
|
+
* Iterates over a sequence, maintaining accumulators that are updated across iterations.
|
|
1042
|
+
* Each iteration can output content and update accumulator values.
|
|
1043
|
+
* After all iterations complete, optional xsl:on-completion is executed.
|
|
1044
|
+
*
|
|
1045
|
+
* @param context The Expression Context.
|
|
1046
|
+
* @param template The template.
|
|
1047
|
+
* @param output The output.
|
|
1048
|
+
*/
|
|
1049
|
+
protected xsltIterate(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1050
|
+
/**
|
|
1051
|
+
* Implements `xsl:try`.
|
|
1052
|
+
* @param context The Expression Context.
|
|
1053
|
+
* @param template The template.
|
|
1054
|
+
* @param output The output.
|
|
1055
|
+
*/
|
|
1056
|
+
protected xsltTry(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Implements `xsl:evaluate` (XSLT 3.0).
|
|
1059
|
+
* Dynamically evaluates an XPath expression constructed as a string.
|
|
1060
|
+
* @param context The Expression Context.
|
|
1061
|
+
* @param template The template.
|
|
1062
|
+
* @param output The output.
|
|
1063
|
+
*/
|
|
1064
|
+
protected xsltEvaluate(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
884
1065
|
/**
|
|
885
1066
|
* Implements `xsl:if`.
|
|
886
1067
|
* @param context The Expression Context.
|
|
@@ -911,6 +1092,60 @@ declare class Xslt {
|
|
|
911
1092
|
* @param output The output.
|
|
912
1093
|
*/
|
|
913
1094
|
protected xsltInclude(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Implements `<xsl:package>` (XSLT 3.0 Section 3.6).
|
|
1097
|
+
* Defines a package of XSLT components with controlled visibility.
|
|
1098
|
+
* @param context The Expression Context.
|
|
1099
|
+
* @param template The xsl:package element.
|
|
1100
|
+
* @param output The output node.
|
|
1101
|
+
*/
|
|
1102
|
+
protected xsltPackage(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1103
|
+
/**
|
|
1104
|
+
* Implements `<xsl:use-package>` (XSLT 3.0 Section 3.7).
|
|
1105
|
+
* Imports another package and makes its public components available.
|
|
1106
|
+
* @param context The Expression Context.
|
|
1107
|
+
* @param template The xsl:use-package element.
|
|
1108
|
+
* @param output The output node.
|
|
1109
|
+
*/
|
|
1110
|
+
protected xsltUsePackage(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1111
|
+
/**
|
|
1112
|
+
* Implements `<xsl:expose>` (XSLT 3.0 Section 3.8).
|
|
1113
|
+
* Marks a component as visible outside the package.
|
|
1114
|
+
* @param context The Expression Context.
|
|
1115
|
+
* @param template The xsl:expose element.
|
|
1116
|
+
*/
|
|
1117
|
+
protected xsltExpose(context: ExprContext, template: XNode): void;
|
|
1118
|
+
/**
|
|
1119
|
+
* Implements `<xsl:accept>` (XSLT 3.0 Section 3.9).
|
|
1120
|
+
* Accepts and optionally overrides a component from a used package.
|
|
1121
|
+
* @param context The Expression Context.
|
|
1122
|
+
* @param template The xsl:accept element.
|
|
1123
|
+
*/
|
|
1124
|
+
protected xsltAccept(context: ExprContext, template: XNode): void;
|
|
1125
|
+
/**
|
|
1126
|
+
* Implements `<xsl:stream>` (XSLT 3.0 Section 16).
|
|
1127
|
+
* Enables streaming processing of large documents.
|
|
1128
|
+
* @param context The Expression Context.
|
|
1129
|
+
* @param template The xsl:stream element.
|
|
1130
|
+
* @param output The output node.
|
|
1131
|
+
*/
|
|
1132
|
+
protected xsltStream(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Implements `<xsl:fork>` (XSLT 3.0 Section 17).
|
|
1135
|
+
* Creates multiple independent output branches from the input stream.
|
|
1136
|
+
* @param context The Expression Context.
|
|
1137
|
+
* @param template The xsl:fork element.
|
|
1138
|
+
* @param output The output node.
|
|
1139
|
+
*/
|
|
1140
|
+
protected xsltFork(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1141
|
+
/**
|
|
1142
|
+
* Implements `<xsl:merge>` (XSLT 3.0 Section 15).
|
|
1143
|
+
* Merges multiple sorted input sequences.
|
|
1144
|
+
* @param context The Expression Context.
|
|
1145
|
+
* @param template The xsl:merge element.
|
|
1146
|
+
* @param output The output node.
|
|
1147
|
+
*/
|
|
1148
|
+
protected xsltMerge(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
914
1149
|
/**
|
|
915
1150
|
* Implements `xsl:key`.
|
|
916
1151
|
* @param context The Expression Context.
|
|
@@ -1098,6 +1333,102 @@ declare class Xslt {
|
|
|
1098
1333
|
*/
|
|
1099
1334
|
protected xsltTransformOrStylesheet(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1100
1335
|
protected xsltValueOf(context: ExprContext, template: XNode, output?: XNode): void;
|
|
1336
|
+
/**
|
|
1337
|
+
* Implements `xsl:sequence` (XSLT 2.0).
|
|
1338
|
+
*
|
|
1339
|
+
* Constructs a sequence by evaluating the select expression or processing
|
|
1340
|
+
* child content. Unlike xsl:copy-of, xsl:sequence returns nodes by reference
|
|
1341
|
+
* and can return atomic values.
|
|
1342
|
+
*
|
|
1343
|
+
* @param context The expression context.
|
|
1344
|
+
* @param template The xsl:sequence element.
|
|
1345
|
+
* @param output The output node.
|
|
1346
|
+
*/
|
|
1347
|
+
protected xsltSequence(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1348
|
+
/**
|
|
1349
|
+
* Implements `xsl:analyze-string` (XSLT 2.0).
|
|
1350
|
+
*
|
|
1351
|
+
* Processes a string using a regular expression, with separate handling
|
|
1352
|
+
* for matching and non-matching substrings.
|
|
1353
|
+
*
|
|
1354
|
+
* @param context The expression context.
|
|
1355
|
+
* @param template The xsl:analyze-string element.
|
|
1356
|
+
* @param output The output node.
|
|
1357
|
+
*/
|
|
1358
|
+
protected xsltAnalyzeString(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1359
|
+
/**
|
|
1360
|
+
* Helper method to process xsl:matching-substring or xsl:non-matching-substring content.
|
|
1361
|
+
* Sets up the context with the current text and regex groups.
|
|
1362
|
+
*/
|
|
1363
|
+
private processAnalyzeStringContent;
|
|
1364
|
+
/**
|
|
1365
|
+
* Implements `xsl:function` (XSLT 2.0).
|
|
1366
|
+
*
|
|
1367
|
+
* Declares a stylesheet function that can be called from XPath expressions.
|
|
1368
|
+
* Functions are collected during stylesheet initialization and made available
|
|
1369
|
+
* to the XPath evaluator.
|
|
1370
|
+
*
|
|
1371
|
+
* @param context The expression context.
|
|
1372
|
+
* @param template The xsl:function element.
|
|
1373
|
+
*/
|
|
1374
|
+
protected xsltFunction(context: ExprContext, template: XNode): void;
|
|
1375
|
+
/**
|
|
1376
|
+
* Execute a user-defined xsl:function.
|
|
1377
|
+
* Called when a function from userDefinedFunctions is invoked from XPath.
|
|
1378
|
+
*
|
|
1379
|
+
* @param context The expression context.
|
|
1380
|
+
* @param functionDef The xsl:function node.
|
|
1381
|
+
* @param args The evaluated arguments passed to the function.
|
|
1382
|
+
* @returns The result of the function execution.
|
|
1383
|
+
*/
|
|
1384
|
+
protected executeUserDefinedFunction(context: ExprContext, functionDef: XNode, args: any[]): Promise<any>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Synchronously execute a user-defined xsl:function.
|
|
1387
|
+
* This is used when functions are called from XPath expressions.
|
|
1388
|
+
* Limited to functions that don't require async operations in their body.
|
|
1389
|
+
*
|
|
1390
|
+
* @param context The expression context.
|
|
1391
|
+
* @param functionDef The xsl:function node.
|
|
1392
|
+
* @param args The evaluated arguments passed to the function.
|
|
1393
|
+
* @returns The result of the function execution.
|
|
1394
|
+
*/
|
|
1395
|
+
executeUserDefinedFunctionSync(context: ExprContext, functionDef: XNode, args: any[]): any;
|
|
1396
|
+
/**
|
|
1397
|
+
* Implements `xsl:result-document` (XSLT 2.0).
|
|
1398
|
+
*
|
|
1399
|
+
* Creates a secondary output document. The output is stored in the
|
|
1400
|
+
* resultDocuments map, accessible via getResultDocuments().
|
|
1401
|
+
*
|
|
1402
|
+
* @param context The expression context.
|
|
1403
|
+
* @param template The xsl:result-document element.
|
|
1404
|
+
*/
|
|
1405
|
+
protected xsltResultDocument(context: ExprContext, template: XNode): Promise<void>;
|
|
1406
|
+
/**
|
|
1407
|
+
* Get all result documents created by xsl:result-document.
|
|
1408
|
+
* @returns A map of href URIs to serialized output strings.
|
|
1409
|
+
*/
|
|
1410
|
+
getResultDocuments(): Map<string, string>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Implements `xsl:perform-sort` (XSLT 2.0).
|
|
1413
|
+
*
|
|
1414
|
+
* Sorts a sequence of items without iteration. The sorted sequence
|
|
1415
|
+
* is available via xsl:sequence or other sequence-consuming instructions.
|
|
1416
|
+
*
|
|
1417
|
+
* @param context The expression context.
|
|
1418
|
+
* @param template The xsl:perform-sort element.
|
|
1419
|
+
* @param output The output node.
|
|
1420
|
+
*/
|
|
1421
|
+
protected xsltPerformSort(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1422
|
+
/**
|
|
1423
|
+
* Implements `xsl:namespace` (XSLT 2.0).
|
|
1424
|
+
*
|
|
1425
|
+
* Creates a namespace node in the result tree.
|
|
1426
|
+
*
|
|
1427
|
+
* @param context The expression context.
|
|
1428
|
+
* @param template The xsl:namespace element.
|
|
1429
|
+
* @param output The output node.
|
|
1430
|
+
*/
|
|
1431
|
+
protected xsltNamespace(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1101
1432
|
/**
|
|
1102
1433
|
* Evaluates a variable or parameter and set it in the current input
|
|
1103
1434
|
* context. Implements `xsl:variable`, `xsl:param`, and `xsl:with-param`.
|
|
@@ -1119,6 +1450,12 @@ declare class Xslt {
|
|
|
1119
1450
|
* @param output If set, the output where the transformation should occur.
|
|
1120
1451
|
*/
|
|
1121
1452
|
protected xsltChildNodes(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1453
|
+
/**
|
|
1454
|
+
* Processes child nodes while skipping xsl:on-empty and xsl:on-non-empty.
|
|
1455
|
+
* Used by instructions that handle these conditionals explicitly.
|
|
1456
|
+
*/
|
|
1457
|
+
protected xsltChildNodesExcludingConditional(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
1458
|
+
private findConditionalChild;
|
|
1122
1459
|
/**
|
|
1123
1460
|
* This logic is used in two different places:
|
|
1124
1461
|
* - `xsltPassThrough`, if the template asks this library to write a text node;
|
|
@@ -1161,6 +1498,16 @@ declare class Xslt {
|
|
|
1161
1498
|
* @returns TODO
|
|
1162
1499
|
*/
|
|
1163
1500
|
protected xsltAttributeValue(value: any, context: ExprContext): any;
|
|
1501
|
+
/**
|
|
1502
|
+
* Evaluates text value templates in XSLT 3.0. Text value templates
|
|
1503
|
+
* allow XPath expressions in braces {} within text nodes.
|
|
1504
|
+
* The expressions are evaluated in the current input context.
|
|
1505
|
+
* To include a literal brace, use {{ or }}.
|
|
1506
|
+
* @param value The text node value to process
|
|
1507
|
+
* @param context The expression context
|
|
1508
|
+
* @returns The processed text with expressions evaluated
|
|
1509
|
+
*/
|
|
1510
|
+
protected xsltTextValueTemplate(value: string, context: ExprContext): string;
|
|
1164
1511
|
/**
|
|
1165
1512
|
* Evaluates an XPath expression in the current input context as a
|
|
1166
1513
|
* match.
|
|
@@ -1193,6 +1540,19 @@ declare class Xslt {
|
|
|
1193
1540
|
* @param stylesheetElement The stylesheet or transform element.
|
|
1194
1541
|
*/
|
|
1195
1542
|
private collectAttributeSets;
|
|
1543
|
+
/**
|
|
1544
|
+
* Collect all user-defined function definitions from the stylesheet.
|
|
1545
|
+
* Called at stylesheet initialization time.
|
|
1546
|
+
* @param stylesheetElement The stylesheet or transform element.
|
|
1547
|
+
* @param context The expression context.
|
|
1548
|
+
*/
|
|
1549
|
+
private collectUserDefinedFunctions;
|
|
1550
|
+
/**
|
|
1551
|
+
* Register user-defined functions in the expression context.
|
|
1552
|
+
* This makes them available to XPath expressions.
|
|
1553
|
+
* @param context The expression context.
|
|
1554
|
+
*/
|
|
1555
|
+
private registerUserDefinedFunctionsInContext;
|
|
1196
1556
|
/**
|
|
1197
1557
|
* Apply one or more attribute sets to an element.
|
|
1198
1558
|
* Parses space-separated attribute set names and applies them.
|