xslt-processor 4.6.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 +70 -7
- package/index.d.ts +70 -7
- package/index.js +4606 -2369
- package/index.js.map +1 -1
- package/index.mjs +4598 -2361
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/umd/xslt-processor.global.js +3 -3
- package/umd/xslt-processor.global.js.map +1 -1
package/index.d.mts
CHANGED
|
@@ -308,13 +308,24 @@ interface XPathContext {
|
|
|
308
308
|
*/
|
|
309
309
|
functionRegistry?: XPathFunctionRegistry;
|
|
310
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
|
+
}
|
|
311
322
|
/**
|
|
312
323
|
* Result types that can be returned from XPath evaluation.
|
|
313
324
|
*
|
|
314
325
|
* XPath 1.0: node-set, string, number, boolean
|
|
315
326
|
* XPath 2.0+: sequences (which subsume node-sets), atomic values, functions
|
|
316
327
|
*/
|
|
317
|
-
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null |
|
|
328
|
+
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null | XPathFunctionItem;
|
|
318
329
|
|
|
319
330
|
declare abstract class XPathExpression {
|
|
320
331
|
abstract evaluate(context: XPathContext): XPathResult;
|
|
@@ -694,6 +705,15 @@ declare class Xslt {
|
|
|
694
705
|
outputOmitXmlDeclaration: string;
|
|
695
706
|
version: string;
|
|
696
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;
|
|
697
717
|
/**
|
|
698
718
|
* List of element name patterns from xsl:strip-space declarations.
|
|
699
719
|
* Whitespace-only text nodes inside matching elements will be stripped.
|
|
@@ -756,6 +776,21 @@ declare class Xslt {
|
|
|
756
776
|
* @param output If set, the output where the transformation should occur.
|
|
757
777
|
*/
|
|
758
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>;
|
|
759
794
|
/**
|
|
760
795
|
* Implements `xsl:apply-templates`.
|
|
761
796
|
* @param context The Expression Context.
|
|
@@ -909,29 +944,57 @@ declare class Xslt {
|
|
|
909
944
|
* @param context The Expression Context.
|
|
910
945
|
* @param level The counting level: 'single', 'multiple', or 'any'.
|
|
911
946
|
* @param count Pattern to match nodes to count.
|
|
912
|
-
* @param from Pattern to
|
|
913
|
-
* @returns
|
|
947
|
+
* @param from Pattern to define counting boundary.
|
|
948
|
+
* @returns Array of count values (single element for 'single'/'any', multiple for 'multiple').
|
|
914
949
|
*/
|
|
915
|
-
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[];
|
|
916
951
|
/**
|
|
917
|
-
* Checks if a node matches a simple
|
|
952
|
+
* Checks if a node matches a pattern (supports simple names and union patterns).
|
|
918
953
|
* @param node The node to check.
|
|
919
|
-
* @param pattern The pattern (node name
|
|
954
|
+
* @param pattern The pattern (node name, wildcard, or union like "a|b|c").
|
|
920
955
|
* @returns True if the node matches.
|
|
921
956
|
*/
|
|
922
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;
|
|
923
965
|
/**
|
|
924
966
|
* Gets all nodes preceding the given node in document order.
|
|
925
967
|
* @param node The reference node.
|
|
968
|
+
* @param fromPattern Optional pattern to define counting boundary.
|
|
926
969
|
* @returns Array of preceding nodes.
|
|
927
970
|
*/
|
|
928
|
-
protected getAllPrecedingNodes(node: XNode): XNode[];
|
|
971
|
+
protected getAllPrecedingNodes(node: XNode, fromPattern?: string | null): XNode[];
|
|
929
972
|
/**
|
|
930
973
|
* Collects all descendant nodes of a given node.
|
|
931
974
|
* @param node The parent node.
|
|
932
975
|
* @param result The array to collect into.
|
|
933
976
|
*/
|
|
934
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
|
+
};
|
|
935
998
|
/**
|
|
936
999
|
* Formats a number according to the format string.
|
|
937
1000
|
* @param number The number to format.
|
package/index.d.ts
CHANGED
|
@@ -308,13 +308,24 @@ interface XPathContext {
|
|
|
308
308
|
*/
|
|
309
309
|
functionRegistry?: XPathFunctionRegistry;
|
|
310
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
|
+
}
|
|
311
322
|
/**
|
|
312
323
|
* Result types that can be returned from XPath evaluation.
|
|
313
324
|
*
|
|
314
325
|
* XPath 1.0: node-set, string, number, boolean
|
|
315
326
|
* XPath 2.0+: sequences (which subsume node-sets), atomic values, functions
|
|
316
327
|
*/
|
|
317
|
-
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null |
|
|
328
|
+
type XPathResult = XPathNode[] | string | number | boolean | any[] | Map<any, any> | null | XPathFunctionItem;
|
|
318
329
|
|
|
319
330
|
declare abstract class XPathExpression {
|
|
320
331
|
abstract evaluate(context: XPathContext): XPathResult;
|
|
@@ -694,6 +705,15 @@ declare class Xslt {
|
|
|
694
705
|
outputOmitXmlDeclaration: string;
|
|
695
706
|
version: string;
|
|
696
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;
|
|
697
717
|
/**
|
|
698
718
|
* List of element name patterns from xsl:strip-space declarations.
|
|
699
719
|
* Whitespace-only text nodes inside matching elements will be stripped.
|
|
@@ -756,6 +776,21 @@ declare class Xslt {
|
|
|
756
776
|
* @param output If set, the output where the transformation should occur.
|
|
757
777
|
*/
|
|
758
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>;
|
|
759
794
|
/**
|
|
760
795
|
* Implements `xsl:apply-templates`.
|
|
761
796
|
* @param context The Expression Context.
|
|
@@ -909,29 +944,57 @@ declare class Xslt {
|
|
|
909
944
|
* @param context The Expression Context.
|
|
910
945
|
* @param level The counting level: 'single', 'multiple', or 'any'.
|
|
911
946
|
* @param count Pattern to match nodes to count.
|
|
912
|
-
* @param from Pattern to
|
|
913
|
-
* @returns
|
|
947
|
+
* @param from Pattern to define counting boundary.
|
|
948
|
+
* @returns Array of count values (single element for 'single'/'any', multiple for 'multiple').
|
|
914
949
|
*/
|
|
915
|
-
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[];
|
|
916
951
|
/**
|
|
917
|
-
* Checks if a node matches a simple
|
|
952
|
+
* Checks if a node matches a pattern (supports simple names and union patterns).
|
|
918
953
|
* @param node The node to check.
|
|
919
|
-
* @param pattern The pattern (node name
|
|
954
|
+
* @param pattern The pattern (node name, wildcard, or union like "a|b|c").
|
|
920
955
|
* @returns True if the node matches.
|
|
921
956
|
*/
|
|
922
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;
|
|
923
965
|
/**
|
|
924
966
|
* Gets all nodes preceding the given node in document order.
|
|
925
967
|
* @param node The reference node.
|
|
968
|
+
* @param fromPattern Optional pattern to define counting boundary.
|
|
926
969
|
* @returns Array of preceding nodes.
|
|
927
970
|
*/
|
|
928
|
-
protected getAllPrecedingNodes(node: XNode): XNode[];
|
|
971
|
+
protected getAllPrecedingNodes(node: XNode, fromPattern?: string | null): XNode[];
|
|
929
972
|
/**
|
|
930
973
|
* Collects all descendant nodes of a given node.
|
|
931
974
|
* @param node The parent node.
|
|
932
975
|
* @param result The array to collect into.
|
|
933
976
|
*/
|
|
934
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
|
+
};
|
|
935
998
|
/**
|
|
936
999
|
* Formats a number according to the format string.
|
|
937
1000
|
* @param number The number to format.
|