xslt-processor 4.4.1 → 4.5.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 +101 -0
- package/index.d.ts +101 -0
- package/index.js +388 -20
- package/index.js.map +1 -1
- package/index.mjs +388 -20
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/umd/xslt-processor.global.js +2 -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
|
/**
|
|
@@ -598,6 +599,37 @@ declare class Xslt {
|
|
|
598
599
|
* Maps stylesheet namespace prefixes to result namespace prefixes.
|
|
599
600
|
*/
|
|
600
601
|
namespaceAliases: Map<string, string>;
|
|
602
|
+
/**
|
|
603
|
+
* Set of supported extension element namespaces.
|
|
604
|
+
* Processors can register custom extension namespaces here.
|
|
605
|
+
* Currently only XSLT namespace is auto-registered.
|
|
606
|
+
*/
|
|
607
|
+
supportedExtensions: Set<string>;
|
|
608
|
+
/**
|
|
609
|
+
* Map of attribute sets defined in the stylesheet.
|
|
610
|
+
* Keys are attribute set names, values are arrays of xsl:attribute nodes.
|
|
611
|
+
*/
|
|
612
|
+
attributeSets: Map<string, XNode[]>;
|
|
613
|
+
/**
|
|
614
|
+
* Stack of stylesheet metadata for tracking import hierarchy.
|
|
615
|
+
* Used by apply-imports to find templates from imported stylesheets.
|
|
616
|
+
*/
|
|
617
|
+
private styleSheetStack;
|
|
618
|
+
/**
|
|
619
|
+
* Map of imported stylesheet HREFs to their parsed XNodes.
|
|
620
|
+
* Prevents duplicate imports and allows precedence tracking.
|
|
621
|
+
*/
|
|
622
|
+
private importedStylesheets;
|
|
623
|
+
/**
|
|
624
|
+
* Map templates to the stylesheet they came from.
|
|
625
|
+
* Enables apply-imports to find templates by import precedence.
|
|
626
|
+
*/
|
|
627
|
+
private templateSourceMap;
|
|
628
|
+
/**
|
|
629
|
+
* Stack of currently executing templates with their metadata.
|
|
630
|
+
* Used by apply-imports to determine which template called it.
|
|
631
|
+
*/
|
|
632
|
+
private currentTemplateStack;
|
|
601
633
|
constructor(options?: Partial<XsltOptions>);
|
|
602
634
|
/**
|
|
603
635
|
* The exported entry point of the XSL-T processor.
|
|
@@ -621,6 +653,16 @@ declare class Xslt {
|
|
|
621
653
|
* @protected
|
|
622
654
|
*/
|
|
623
655
|
protected xsltApplyTemplates(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
656
|
+
/**
|
|
657
|
+
* Implements `xsl:apply-imports`.
|
|
658
|
+
* Applies templates from imported stylesheets with the same match pattern and mode.
|
|
659
|
+
* This enables template overriding where a template in an importing stylesheet
|
|
660
|
+
* can call the overridden template from the imported stylesheet.
|
|
661
|
+
* @param context The Expression Context.
|
|
662
|
+
* @param template The apply-imports template node.
|
|
663
|
+
* @param output The output node.
|
|
664
|
+
*/
|
|
665
|
+
protected xsltApplyImports(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
624
666
|
/**
|
|
625
667
|
* Implements `xsl:attribute`.
|
|
626
668
|
* @param context The Expression Context.
|
|
@@ -658,6 +700,13 @@ declare class Xslt {
|
|
|
658
700
|
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
659
701
|
*/
|
|
660
702
|
protected xsltComment(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
703
|
+
/**
|
|
704
|
+
* Implements `xsl:processing-instruction`.
|
|
705
|
+
* @param context The Expression Context.
|
|
706
|
+
* @param template The template.
|
|
707
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
708
|
+
*/
|
|
709
|
+
protected xsltProcessingInstruction(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
661
710
|
/**
|
|
662
711
|
* Implements `xsl:copy-of` for node-set values of the select
|
|
663
712
|
* expression. Recurses down the source node tree, which is part of
|
|
@@ -957,6 +1006,58 @@ declare class Xslt {
|
|
|
957
1006
|
* @param template The template node.
|
|
958
1007
|
*/
|
|
959
1008
|
protected xsltWithParam(context: ExprContext, template: XNode): Promise<void>;
|
|
1009
|
+
/**
|
|
1010
|
+
* Recursively map all template nodes in a stylesheet to their metadata.
|
|
1011
|
+
* Used to track which stylesheet each template comes from for apply-imports.
|
|
1012
|
+
* @param stylesheetElement The stylesheet or transform element (or any parent element).
|
|
1013
|
+
* @param metadata The metadata for this stylesheet.
|
|
1014
|
+
*/
|
|
1015
|
+
private mapTemplatesFromStylesheet;
|
|
1016
|
+
/**
|
|
1017
|
+
* Collect all attribute set definitions from the stylesheet.
|
|
1018
|
+
* Called at stylesheet initialization time.
|
|
1019
|
+
* @param stylesheetElement The stylesheet or transform element.
|
|
1020
|
+
*/
|
|
1021
|
+
private collectAttributeSets;
|
|
1022
|
+
/**
|
|
1023
|
+
* Apply one or more attribute sets to an element.
|
|
1024
|
+
* Parses space-separated attribute set names and applies them.
|
|
1025
|
+
* @param context The Expression Context.
|
|
1026
|
+
* @param element The element to apply attributes to.
|
|
1027
|
+
* @param setNames Space-separated attribute set names.
|
|
1028
|
+
*/
|
|
1029
|
+
protected applyAttributeSets(context: ExprContext, element: XNode, setNames: string): Promise<void>;
|
|
1030
|
+
/**
|
|
1031
|
+
* Apply a single attribute set to an element.
|
|
1032
|
+
* Handles recursive attribute sets with cycle detection.
|
|
1033
|
+
* @param context The Expression Context.
|
|
1034
|
+
* @param element The element to apply attributes to.
|
|
1035
|
+
* @param setName The name of the attribute set to apply.
|
|
1036
|
+
* @param processedSets Set of already-processed attribute set names (for cycle detection).
|
|
1037
|
+
*/
|
|
1038
|
+
private applyAttributeSet;
|
|
1039
|
+
/**
|
|
1040
|
+
* Test if an element is a supported extension.
|
|
1041
|
+
* Returns false for unrecognized elements in non-XSLT namespaces.
|
|
1042
|
+
* @param node The element to test.
|
|
1043
|
+
* @returns True if the element is supported, false if it's an unrecognized extension.
|
|
1044
|
+
*/
|
|
1045
|
+
protected isExtensionElementSupported(node: XNode): boolean;
|
|
1046
|
+
/**
|
|
1047
|
+
* Get the fallback element from an extension element if it exists.
|
|
1048
|
+
* Searches for the first direct xsl:fallback child.
|
|
1049
|
+
* @param node The extension element.
|
|
1050
|
+
* @returns The fallback element, or null if not found.
|
|
1051
|
+
*/
|
|
1052
|
+
protected getFallbackElement(node: XNode): XNode | null;
|
|
1053
|
+
/**
|
|
1054
|
+
* Process an extension element with fallback support.
|
|
1055
|
+
* If a fallback is defined, executes it; otherwise treats element as literal.
|
|
1056
|
+
* @param context The Expression Context.
|
|
1057
|
+
* @param element The extension element.
|
|
1058
|
+
* @param output The output node.
|
|
1059
|
+
*/
|
|
1060
|
+
protected xsltExtensionElement(context: ExprContext, element: XNode, output?: XNode): Promise<void>;
|
|
960
1061
|
/**
|
|
961
1062
|
* Test if the given element is an XSLT element, optionally the one with the given name.
|
|
962
1063
|
* @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
|
/**
|
|
@@ -598,6 +599,37 @@ declare class Xslt {
|
|
|
598
599
|
* Maps stylesheet namespace prefixes to result namespace prefixes.
|
|
599
600
|
*/
|
|
600
601
|
namespaceAliases: Map<string, string>;
|
|
602
|
+
/**
|
|
603
|
+
* Set of supported extension element namespaces.
|
|
604
|
+
* Processors can register custom extension namespaces here.
|
|
605
|
+
* Currently only XSLT namespace is auto-registered.
|
|
606
|
+
*/
|
|
607
|
+
supportedExtensions: Set<string>;
|
|
608
|
+
/**
|
|
609
|
+
* Map of attribute sets defined in the stylesheet.
|
|
610
|
+
* Keys are attribute set names, values are arrays of xsl:attribute nodes.
|
|
611
|
+
*/
|
|
612
|
+
attributeSets: Map<string, XNode[]>;
|
|
613
|
+
/**
|
|
614
|
+
* Stack of stylesheet metadata for tracking import hierarchy.
|
|
615
|
+
* Used by apply-imports to find templates from imported stylesheets.
|
|
616
|
+
*/
|
|
617
|
+
private styleSheetStack;
|
|
618
|
+
/**
|
|
619
|
+
* Map of imported stylesheet HREFs to their parsed XNodes.
|
|
620
|
+
* Prevents duplicate imports and allows precedence tracking.
|
|
621
|
+
*/
|
|
622
|
+
private importedStylesheets;
|
|
623
|
+
/**
|
|
624
|
+
* Map templates to the stylesheet they came from.
|
|
625
|
+
* Enables apply-imports to find templates by import precedence.
|
|
626
|
+
*/
|
|
627
|
+
private templateSourceMap;
|
|
628
|
+
/**
|
|
629
|
+
* Stack of currently executing templates with their metadata.
|
|
630
|
+
* Used by apply-imports to determine which template called it.
|
|
631
|
+
*/
|
|
632
|
+
private currentTemplateStack;
|
|
601
633
|
constructor(options?: Partial<XsltOptions>);
|
|
602
634
|
/**
|
|
603
635
|
* The exported entry point of the XSL-T processor.
|
|
@@ -621,6 +653,16 @@ declare class Xslt {
|
|
|
621
653
|
* @protected
|
|
622
654
|
*/
|
|
623
655
|
protected xsltApplyTemplates(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
656
|
+
/**
|
|
657
|
+
* Implements `xsl:apply-imports`.
|
|
658
|
+
* Applies templates from imported stylesheets with the same match pattern and mode.
|
|
659
|
+
* This enables template overriding where a template in an importing stylesheet
|
|
660
|
+
* can call the overridden template from the imported stylesheet.
|
|
661
|
+
* @param context The Expression Context.
|
|
662
|
+
* @param template The apply-imports template node.
|
|
663
|
+
* @param output The output node.
|
|
664
|
+
*/
|
|
665
|
+
protected xsltApplyImports(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
624
666
|
/**
|
|
625
667
|
* Implements `xsl:attribute`.
|
|
626
668
|
* @param context The Expression Context.
|
|
@@ -658,6 +700,13 @@ declare class Xslt {
|
|
|
658
700
|
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
659
701
|
*/
|
|
660
702
|
protected xsltComment(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
703
|
+
/**
|
|
704
|
+
* Implements `xsl:processing-instruction`.
|
|
705
|
+
* @param context The Expression Context.
|
|
706
|
+
* @param template The template.
|
|
707
|
+
* @param output The output. Only used if there's no corresponding output node already defined.
|
|
708
|
+
*/
|
|
709
|
+
protected xsltProcessingInstruction(context: ExprContext, template: XNode, output?: XNode): Promise<void>;
|
|
661
710
|
/**
|
|
662
711
|
* Implements `xsl:copy-of` for node-set values of the select
|
|
663
712
|
* expression. Recurses down the source node tree, which is part of
|
|
@@ -957,6 +1006,58 @@ declare class Xslt {
|
|
|
957
1006
|
* @param template The template node.
|
|
958
1007
|
*/
|
|
959
1008
|
protected xsltWithParam(context: ExprContext, template: XNode): Promise<void>;
|
|
1009
|
+
/**
|
|
1010
|
+
* Recursively map all template nodes in a stylesheet to their metadata.
|
|
1011
|
+
* Used to track which stylesheet each template comes from for apply-imports.
|
|
1012
|
+
* @param stylesheetElement The stylesheet or transform element (or any parent element).
|
|
1013
|
+
* @param metadata The metadata for this stylesheet.
|
|
1014
|
+
*/
|
|
1015
|
+
private mapTemplatesFromStylesheet;
|
|
1016
|
+
/**
|
|
1017
|
+
* Collect all attribute set definitions from the stylesheet.
|
|
1018
|
+
* Called at stylesheet initialization time.
|
|
1019
|
+
* @param stylesheetElement The stylesheet or transform element.
|
|
1020
|
+
*/
|
|
1021
|
+
private collectAttributeSets;
|
|
1022
|
+
/**
|
|
1023
|
+
* Apply one or more attribute sets to an element.
|
|
1024
|
+
* Parses space-separated attribute set names and applies them.
|
|
1025
|
+
* @param context The Expression Context.
|
|
1026
|
+
* @param element The element to apply attributes to.
|
|
1027
|
+
* @param setNames Space-separated attribute set names.
|
|
1028
|
+
*/
|
|
1029
|
+
protected applyAttributeSets(context: ExprContext, element: XNode, setNames: string): Promise<void>;
|
|
1030
|
+
/**
|
|
1031
|
+
* Apply a single attribute set to an element.
|
|
1032
|
+
* Handles recursive attribute sets with cycle detection.
|
|
1033
|
+
* @param context The Expression Context.
|
|
1034
|
+
* @param element The element to apply attributes to.
|
|
1035
|
+
* @param setName The name of the attribute set to apply.
|
|
1036
|
+
* @param processedSets Set of already-processed attribute set names (for cycle detection).
|
|
1037
|
+
*/
|
|
1038
|
+
private applyAttributeSet;
|
|
1039
|
+
/**
|
|
1040
|
+
* Test if an element is a supported extension.
|
|
1041
|
+
* Returns false for unrecognized elements in non-XSLT namespaces.
|
|
1042
|
+
* @param node The element to test.
|
|
1043
|
+
* @returns True if the element is supported, false if it's an unrecognized extension.
|
|
1044
|
+
*/
|
|
1045
|
+
protected isExtensionElementSupported(node: XNode): boolean;
|
|
1046
|
+
/**
|
|
1047
|
+
* Get the fallback element from an extension element if it exists.
|
|
1048
|
+
* Searches for the first direct xsl:fallback child.
|
|
1049
|
+
* @param node The extension element.
|
|
1050
|
+
* @returns The fallback element, or null if not found.
|
|
1051
|
+
*/
|
|
1052
|
+
protected getFallbackElement(node: XNode): XNode | null;
|
|
1053
|
+
/**
|
|
1054
|
+
* Process an extension element with fallback support.
|
|
1055
|
+
* If a fallback is defined, executes it; otherwise treats element as literal.
|
|
1056
|
+
* @param context The Expression Context.
|
|
1057
|
+
* @param element The extension element.
|
|
1058
|
+
* @param output The output node.
|
|
1059
|
+
*/
|
|
1060
|
+
protected xsltExtensionElement(context: ExprContext, element: XNode, output?: XNode): Promise<void>;
|
|
960
1061
|
/**
|
|
961
1062
|
* Test if the given element is an XSLT element, optionally the one with the given name.
|
|
962
1063
|
* @param {XNode} element The element.
|