W3cubDocs

/Web APIs

XSLTProcessor

An XSLTProcessor applies an XSLT stylesheet transformation to an XML document to produce a new XML document as output. It has methods to load the XSLT stylesheet, to manipulate <xsl:param> parameter values, and to apply the transformation to documents.

Constructor

XSLTProcessor()

Create a new XSLTProcessor.

Instance methods

XSLTProcessor.importStylesheet()

Imports the XSLT stylesheet. If the given node is a document node, you can pass in a full XSL Transform or a literal result element transform; otherwise, it must be an <xsl:stylesheet> or <xsl:transform> element.

XSLTProcessor.transformToFragment()

Transforms the node source by applying the XSLT stylesheet imported using the XSLTProcessor.importStylesheet() function. The owner document of the resulting document fragment is the owner node.

XSLTProcessor.transformToDocument()

Transforms the node source applying the XSLT stylesheet given importing using the XSLTProcessor.importStylesheet() function.

XSLTProcessor.setParameter()

Sets a parameter (<xsl:param>) value in the XSLT stylesheet that was imported.

XSLTProcessor.getParameter()

Gets the value of a parameter from the XSLT stylesheet.

XSLTProcessor.removeParameter()

Removes the parameter if it was previously set. This will make the XSLTProcessor use the default value for the parameter as specified in the XSLT stylesheet.

XSLTProcessor.clearParameters()

Removes all set parameters from the XSLTProcessor. The XSLTProcessor will then use the default values specified in the XSLT stylesheet.

XSLTProcessor.reset()

Removes all parameters and stylesheets from the XSLTProcessor.

Instance properties

This are no properties for this interface.

Examples

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
XSLTProcessor 1 12 1 No ≤12.1 3.1 3 18 4 ≤12.1 2 1.0
XSLTProcessor 1 12 1 No ≤12.1 3.1 3 18 4 ≤12.1 2 1.0
clearParameters 1 12 1 No ≤12.1 3.1 3 18 4 ≤12.1 2 1.0
getParameter
1Chrome only supports string values.
12Edge only supports string values.
1 No
≤12.1Opera only supports string values.
3.1Safari only supports string values.
3WebView only supports string values.
18Chrome only supports string values.
4
≤12.1Opera only supports string values.
2Safari only supports string values.
1.0Samsung Internet only supports string values.
importStylesheet 1 12 1 No ≤12.1 3.1 3 18 4 ≤12.1 2 1.0
removeParameter 1 12 1 No ≤12.1 3.1 3 18 4 ≤12.1 2 1.0
reset 1 12 1 No ≤12.1 3.1 3 18 4 ≤12.1 2 1.0
setParameter
1Chrome only supports string values.
12Edge only supports string values.
1 No
≤12.1Opera only supports string values.
3.1Safari only supports string values.
3WebView only supports string values.
18Chrome only supports string values.
4
≤12.1Opera only supports string values.
2Safari only supports string values.
1.0Samsung Internet only supports string values.
transformToDocument
1Chrome returns null if an error occurs.
12Edge returns null if an error occurs.
1Firefox throws an exception if an error occurs.
No
≤12.1["Opera 12.1 and earlier throws an exception if an error occurs.", "Opera 15 and later returns null if an error occurs."]
3.1Safari returns null if an error occurs.
3WebView returns null if an error occurs.
18Chrome returns null if an error occurs.
4Firefox throws an exception if an error occurs.
≤12.1["Opera Android 12.1 and earlier throws an exception if an error occurs.", "Opera Android 14 and later returns null if an error occurs."]
2Safari returns null if an error occurs.
1.0Samsung Internet returns null if an error occurs.
transformToFragment
1Chrome returns null if an error occurs.
12Edge returns null if an error occurs.
1Firefox throws an exception if an error occurs.
No
≤12.1["Opera 12.1 and earlier throws an exception if an error occurs.", "Opera 15 and later returns null if an error occurs."]
3.1Safari returns null if an error occurs.
3WebView returns null if an error occurs.
18Chrome returns null if an error occurs.
4Firefox throws an exception if an error occurs.
≤12.1["Opera Android 12.1 and earlier throws an exception if an error occurs.", "Opera Android 14 and later returns null if an error occurs."]
2Safari returns null if an error occurs.
1.0Samsung Internet returns null if an error occurs.

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XSLTProcessor