Forwards-compatible processing mode (XSLT 1.0 Section 2.5). When true, the processor is running a stylesheet with version > 1.0. In this mode:
List of element name patterns from xsl:strip-space declarations. Whitespace-only text nodes inside matching elements will be stripped.
List of element name patterns from xsl:preserve-space declarations. Whitespace-only text nodes inside matching elements will be preserved. preserve-space takes precedence over strip-space for conflicting patterns.
Namespace aliases from xsl:namespace-alias declarations. Maps stylesheet namespace prefixes to result namespace prefixes.
Set of supported extension element namespaces. Processors can register custom extension namespaces here. Currently only XSLT namespace is auto-registered.
Map of attribute sets defined in the stylesheet. Keys are attribute set names, values are arrays of xsl:attribute nodes.
Map of user-defined functions from xsl:function declarations. Keys are QNames (namespace:localname), values are the function definition nodes.
Result documents created by xsl:result-document. Keys are the href URIs, values are the serialized output strings.
The exported entry point of the XSL-T processor.
The input document root, as DOM node.
The stylesheet document root, as DOM node.
the processed document, as XML text in a string, JSON string if outputMethod is 'json', or text if outputMethod is 'text' or 'adaptive' (with text content).
ProtectedxsltThe main entry point of the XSL-T processor, as explained on the top of the file.
The input document root, as XPath ExprContext.
The stylesheet document root, as DOM node.
Optionaloutput: XNodeIf set, the output where the transformation should occur.
ProtectedxsltHandle unknown XSLT instructions per XSLT 1.0 Section 2.5 (Forwards-Compatible Processing).
In forwards-compatible mode (version > 1.0):
In strict mode (version = 1.0):
The Expression Context
The unknown XSLT instruction element
Optionaloutput: XNodeThe output node
ProtectedxsltProtectedImplements xsl:apply-templates.
The Expression Context.
The template.
Optionaloutput: XNodeThe output. Only used if there's no corresponding output node already defined.
ProtectedxsltImplements xsl:apply-imports.
Applies templates from imported stylesheets with the same match pattern and mode.
This enables template overriding where a template in an importing stylesheet
can call the overridden template from the imported stylesheet.
The Expression Context.
The apply-imports template node.
Optionaloutput: XNodeThe output node.
ProtectedxsltProtectedImplements xsl:attribute.
The Expression Context.
The template.
Optionaloutput: XNodeThe output. Only used if there's no corresponding output node already defined.
ProtectedxsltImplements xsl:call-template.
The Expression Context.
The template.
Optionaloutput: XNodeThe output, used when a fragment is passed by a previous step.
ProtectedxsltImplements xsl:choose, its child nodes xsl:when, and
xsl:otherwise.
The Expression Context.
The template.
Optionaloutput: XNodeThe output. Only used if there's no corresponding output node already defined.
ProtectedxsltImplements xsl:copy for all node types.
the node being copied to, part of output document.
the node being copied, part in input document.
If an element node was created, the element node. Otherwise, null.
ProtectedxsltImplements xsl:comment.
The Expression Context.
The template.
Optionaloutput: XNodeThe output. Only used if there's no corresponding output node already defined.
ProtectedxsltImplements xsl:processing-instruction.
The Expression Context.
The template.
Optionaloutput: XNodeThe output. Only used if there's no corresponding output node already defined.
ProtectedxsltImplements xsl:copy-of for node-set values of the select
expression. Recurses down the source node tree, which is part of
the input document.
the node being copied to, part of output document.
the node being copied, part in input document.
ProtectedxsltImplements xsl:decimal-format, registering the settings in this instance
and the current context.
The Expression Context.
The template.
ProtectedxsltImplements xsl:element.
The Expression Context.
The template.
Optionaloutput: XNodeProtectedxsltImplements xsl:accumulator (XSLT 3.0).
Accumulators are a declarative way to compute values during template processing. They consist of rules that are applied as elements are processed.
The expression context
The xsl:accumulator element
ProtectedevaluateEvaluates all matching accumulator rules for a given node and updates the accumulator state
The expression context with current node
The current node being processed
ProtectedgetRetrieves the current value of an accumulator Used when accessing accumulators in templates via accumulator-after() or accumulator-before()
The name of the accumulator
The current value of the accumulator, or null if not found
ProtectedxsltImplements xsl:for-each.
The Expression Context.
The template.
Optionaloutput: XNodeThe output.
ProtectedxsltImplements xsl:for-each-group (XSLT 2.0).
Groups items from the select expression and processes each group. Supports group-by and group-adjacent grouping methods.
The Expression Context.
The template.
Optionaloutput: XNodeThe output.
ProtectedxsltImplements xsl:iterate (XSLT 3.0).
Iterates over a sequence, maintaining accumulators that are updated across iterations. Each iteration can output content and update accumulator values. After all iterations complete, optional xsl:on-completion is executed.
The Expression Context.
The template.
Optionaloutput: XNodeThe output.
ProtectedxsltImplements xsl:try.
The Expression Context.
The template.
Optionaloutput: XNodeThe output.
ProtectedxsltImplements xsl:evaluate (XSLT 3.0).
Dynamically evaluates an XPath expression constructed as a string.
The Expression Context.
The template.
Optionaloutput: XNodeThe output.
ProtectedxsltImplements xsl:if.
The Expression Context.
The template.
Optionaloutput: XNodeThe output.
ProtectedxsltCommon implementation for <xsl:import> and <xsl:include>.
The Expression Context.
The template.
The output.
Whether this is an import (true) or include (false).
ProtectedxsltImplements <xsl:import>. For now the code is nearly identical to <xsl:include>, but there's
no precedence evaluation implemented yet.
The Expression Context.
The template.
Optionaloutput: XNodeThe output.
ProtectedxsltImplements xsl:include.
The Expression Context.
The template.
Optionaloutput: XNodeThe output.
ProtectedxsltImplements <xsl:package> (XSLT 3.0 Section 3.6).
Defines a package of XSLT components with controlled visibility.
The Expression Context.
The xsl:package element.
Optionaloutput: XNodeThe output node.
ProtectedloadLoads and registers an external package. Creates a temporary context and processes the package document.
The package name/URI.
The parsed package document.
Optionalversion: stringOptional semantic version string.
ProtectedxsltImplements <xsl:use-package> (XSLT 3.0 Section 3.7).
Imports another package and makes its public components available.
The Expression Context.
The xsl:use-package element.
Optionaloutput: XNodeThe output node.
ProtectedxsltImplements <xsl:expose> (XSLT 3.0 Section 3.8).
Marks a component as visible outside the package.
The Expression Context.
The xsl:expose element.
ProtectedxsltImplements <xsl:accept> (XSLT 3.0 Section 3.9).
Accepts and optionally overrides a component from a used package.
The Expression Context.
The xsl:accept element.
ProtectedxsltImplements xsl:override (XSLT 3.0 Section 3.7.2). Overrides components from a used package.
Optionaloutput: XNodeProtectedxsltImplements xsl:original (XSLT 3.0 Section 3.7.2). Calls the original component from within an override.
Optionaloutput: XNodeProtectedxsltImplements <xsl:mode> (XSLT 3.0 Section 3.5).
Declares a mode with visibility and other properties.
Only valid within an xsl:package.
ProtectedxsltImplements <xsl:stream> (XSLT 3.0 Section 16).
Enables streaming processing of large documents.
The Expression Context.
The xsl:stream element.
Optionaloutput: XNodeThe output node.
ProtectedxsltImplements <xsl:fork> (XSLT 3.0 Section 17).
Creates multiple independent output branches from the input stream.
The Expression Context.
The xsl:fork element.
Optionaloutput: XNodeThe output node.
ProtectedxsltImplements <xsl:merge> (XSLT 3.0 Section 15).
Merges multiple sorted input sequences.
The Expression Context.
The xsl:merge element.
Optionaloutput: XNodeThe output node.
ProtectedxsltImplements xsl:key.
The Expression Context.
The template.
ProtectedxsltImplements xsl:message.
Outputs a message to the console. If terminate="yes", throws an error to stop processing.
The Expression Context.
The <xsl:message> node.
ProtectedxsltImplements xsl:namespace-alias.
Declares that a namespace URI in the stylesheet should be replaced by a different
namespace URI in the output.
The <xsl:namespace-alias> node.
ProtectedxsltImplements xsl:number.
Inserts a formatted number into the result tree.
The Expression Context.
The <xsl:number> node.
Optionaloutput: XNodeThe output node.
ProtectedxsltCounts nodes for xsl:number based on level, count, and from attributes.
The Expression Context.
The counting level: 'single', 'multiple', or 'any'.
Pattern to match nodes to count.
Pattern to define counting boundary.
Array of count values (single element for 'single'/'any', multiple for 'multiple').
ProtectednodeChecks if a node matches a pattern (supports simple names and union patterns).
The node to check.
The pattern (node name, wildcard, or union like "a|b|c").
True if the node matches.
ProtectednodeChecks if a node matches a single (non-union) pattern.
The node to check.
The pattern (node name or wildcard).
True if the node matches.
ProtectedgetGets all nodes preceding the given node in document order.
The reference node.
Optional pattern to define counting boundary.
Array of preceding nodes.
ProtectedcollectCollects all descendant nodes of a given node.
The parent node.
The array to collect into.
ProtectedxsltFormats an array of numbers according to the format string. For level="multiple", numbers like [1, 2, 3] with format "1.1.1" produce "1.2.3".
The numbers to format.
The format string (e.g., "1", "1.1", "1.a.i").
Optional grouping separator.
Optional grouping size.
The formatted number string.
ProtectedparseParses a format string into tokens and separators. E.g., "1.a.i" -> tokens: ["1", "a", "i"], separators: [".", "."]
The format string.
Object with tokens and separators arrays.
ProtectedxsltFormats a number according to the format string.
The number to format.
The format string (e.g., "1", "01", "a", "A", "i", "I").
Optional grouping separator.
Optional grouping size.
The formatted number string.
ProtectednumberConverts a number to alphabetic representation.
The number to convert.
Whether to use uppercase letters.
The alphabetic representation.
ProtectednumberConverts a number to Roman numeral representation.
The number to convert.
The Roman numeral string.
ProtectedapplyApplies grouping separators to a numeric string.
The numeric string.
The grouping separator.
The grouping size.
The grouped string.
ProtectedxsltOrders the current node list in the input context according to the sort order specified by xsl:sort child nodes of the current template node. This happens before the operation specified by the current template node is executed.
The expression context.
The template node.
ProtectedxsltImplements xsl:strip-space.
Collects element name patterns for which whitespace-only text nodes should be stripped.
The <xsl:strip-space> node.
ProtectedxsltImplements xsl:preserve-space.
Collects element name patterns for which whitespace-only text nodes should be preserved.
preserve-space takes precedence over strip-space for matching elements.
The <xsl:preserve-space> node.
ProtectedshouldDetermines if a text node from the input document should be stripped. This applies xsl:strip-space and xsl:preserve-space rules to whitespace-only text nodes.
The text node to check.
True if the text node should be stripped (not included in output).
ProtectedmatchesMatches an element name against a strip-space/preserve-space pattern. Supports:
The local name of the element.
The pattern to match against.
The element node (for namespace checking).
True if the element matches the pattern.
ProtectedxsltImplements xsl:template.
The Expression Context.
The <xsl:template> node.
Optionaloutput: XNodeThe output. In general, a fragment that will be used by the caller.
ProtectedxsltOptionaloutput: XNodeProtectedvalidateValidates XSLT stylesheet/transform attributes. According to XSLT specification, validates:
The <xsl:stylesheet> or <xsl:transform> element to validate.
The Expression Context for namespace access.
ProtectedxsltImplements <xsl:stylesheet> and <xsl:transform>, and its corresponding
validations.
The Expression Context.
The <xsl:stylesheet> or <xsl:transform> node.
Optionaloutput: XNodeThe output. In general, a fragment that will be used by the caller.
ProtectedxsltOptionaloutput: XNodeProtectedxsltImplements xsl:sequence (XSLT 2.0).
Constructs a sequence by evaluating the select expression or processing child content. Unlike xsl:copy-of, xsl:sequence returns nodes by reference and can return atomic values.
The expression context.
The xsl:sequence element.
Optionaloutput: XNodeThe output node.
ProtectedxsltImplements xsl:analyze-string (XSLT 2.0).
Processes a string using a regular expression, with separate handling for matching and non-matching substrings.
The expression context.
The xsl:analyze-string element.
Optionaloutput: XNodeThe output node.
ProtectedxsltImplements xsl:function (XSLT 2.0).
Declares a stylesheet function that can be called from XPath expressions. Functions are collected during stylesheet initialization and made available to the XPath evaluator.
The expression context.
The xsl:function element.
ProtectedcoerceCoerce a NodeValue to a specific type based on the 'as' attribute.
The value to coerce.
The target type (e.g., "xs:integer", "xs:string", "xs:boolean").
The coerced value.
ProtectedexecuteExecute a user-defined xsl:function. Called when a function from userDefinedFunctions is invoked from XPath.
The expression context.
The xsl:function node.
The evaluated arguments passed to the function.
The result of the function execution.
Synchronously execute a user-defined xsl:function. This is used when functions are called from XPath expressions. Limited to functions that don't require async operations in their body.
The expression context.
The xsl:function node.
The evaluated arguments passed to the function.
The result of the function execution.
ProtectedxsltImplements xsl:result-document (XSLT 2.0).
Creates a secondary output document. The output is stored in the resultDocuments map, accessible via getResultDocuments().
The expression context.
The xsl:result-document element.
Get all result documents created by xsl:result-document.
A map of href URIs to serialized output strings.
Sets the package loader callback. The callback is called when a package is referenced via xsl:use-package but is not found in the registry.
A function that loads package documents by URI and optional version. Returns the parsed package document, or null if not found.
Pre-registers a package for use in transformations. The package is parsed and stored in the internal registry.
The package name/URI.
The parsed package document.
Optionalversion: stringOptional semantic version string.
ProtectedxsltImplements xsl:perform-sort (XSLT 2.0).
Sorts a sequence of items without iteration. The sorted sequence is available via xsl:sequence or other sequence-consuming instructions.
The expression context.
The xsl:perform-sort element.
Optionaloutput: XNodeThe output node.
ProtectedxsltImplements xsl:namespace (XSLT 2.0).
Creates a namespace node in the result tree.
The expression context.
The xsl:namespace element.
Optionaloutput: XNodeThe output node.
ProtectedxsltEvaluates a variable or parameter and set it in the current input
context. Implements xsl:variable, xsl:param, and xsl:with-param.
The expression context.
The template node.
flag that defines if the value computed here
overrides the one already in the input context if that is the
case. I.e. decides if this is a default value or a local
value. xsl:variable and xsl:with-param override; xsl:param doesn't.
ProtectedxsltTraverses the template node tree. Calls the main processing function with the current input context for every child node of the current template node.
Normally the Expression Context.
The XSL-T definition.
Optionaloutput: XNodeIf set, the output where the transformation should occur.
ProtectedxsltProcesses child nodes while skipping xsl:on-empty and xsl:on-non-empty. Used by instructions that handle these conditionals explicitly.
Optionaloutput: XNodeProtectedxsltPasses template text to the output. The current template node does not specify an XSL-T operation and therefore is appended to the output with all its attributes. Then continues traversing the template node tree.
The Expression Context.
The XSLT stylesheet or transformation.
The output.
ProtectedxsltProtectedfindProtectedxsltEvaluates an XSL-T attribute value template. Attribute value templates are attributes on XSL-T elements that contain XPath expressions in braces {}. The XSL-T expressions are evaluated in the current input context.
TODO
TODO
TODO
ProtectedxsltEvaluates text value templates in XSLT 3.0. Text value templates allow XPath expressions in braces {} within text nodes. The expressions are evaluated in the current input context. To include a literal brace, use {{ or }}.
The text node value to process
The expression context
The processed text with expressions evaluated
ProtectedxsltEvaluates an XPath expression in the current input context as a match.
TODO
The Expression Context.
Optionalaxis: stringThe XPath axis. Used when the match does not start with the parent.
A list of the found nodes.
ProtectedxsltSets parameters defined by xsl:with-param child nodes of the current template node, in the current input context. This happens before the operation specified by the current template node is executed.
The Expression Context.
The template node.
ProtectedapplyApply one or more attribute sets to an element. Parses space-separated attribute set names and applies them.
The Expression Context.
The element to apply attributes to.
Space-separated attribute set names.
ProtectedisTest if an element is a supported extension. Returns false for unrecognized elements in non-XSLT namespaces.
The element to test.
True if the element is supported, false if it's an unrecognized extension.
ProtectedgetGet the fallback element from an extension element if it exists. Searches for the first direct xsl:fallback child.
The extension element.
The fallback element, or null if not found.
ProtectedxsltProcess an extension element with fallback support. If a fallback is defined, executes it; otherwise treats element as literal.
The Expression Context.
The extension element.
Optionaloutput: XNodeThe output node.
ProtectedisTest if the given element is an XSLT element, optionally the one with the given name.
The element.
Optionalopt_wantedName: stringThe name for comparison.
True, if element is an XSL node. False otherwise.
The main class for XSL-T processing.
References:
[XSLT 1.0] XSL Transformations (XSLT) Version 1.0 https://www.w3.org/TR/1999/REC-xslt-19991116.
[XSLT 2.0] XSL Transformations (XSLT) Version 2.0 https://www.w3.org/TR/xslt20/.
[XSLT 3.0] XSL Transformations (XSLT) Version 3.0 https://www.w3.org/TR/xslt-30/.
[ECMA] ECMAScript Language Specification http://www.ecma-international.org/publications/standards/Ecma-262.htm.
The XSL processor API has one entry point: the async function
xsltProcess(). It receives as arguments the input XML document and the XSL-T stylesheet document (both asXDocumentinstances), and returns the transformed output as a string (XML, HTML, JSON, or plain text depending on the output method).NOTE: Strictly speaking, XSL-T processing according to the specification is defined as operation on text documents, not as operation on DOM trees. This implementation operates on an internal DOM representation, complemented by an XML parser and serializer to be complete. Those two are found in the
domfolder.