--- title: XSLTProcessor slug: Web/API/XSLTProcessor tags: - API - DOM - DOM Reference - NeedsTranslation - Reference - TopicStub - XSLT translation_of: Web/API/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.
The constructor has no parameters.
new XSLTProcessor()
[Throws] void {{domxref("XSLTProcessor.importStylesheet")}}({{domxref("Node")}} styleSheet)<xsl:stylesheet> or <xsl:transform> element.[Throws] {{domxref("DocumentFragment")}} {{domxref("XSLTProcessor.transformToFragment")}}({{domxref("Node")}} source, {{domxref("Document")}} owner)[Throws] {{domxref("Document")}} {{domxref("XSLTProcessor.transformToDocument")}}({{domxref("Node")}} source)Transforms the node source applying the stylesheet given importing using the {{domxref("XSLTProcessor.importStylesheet()")}} function.
The resultant object depends on the output method of the stylesheet:
| Output method | Result type |
|---|---|
html |
{{domxref("HTMLDocument")}} |
xml |
{{domxref("XMLDocument")}} |
text |
{{domxref("XMLDocument")}} with a single root element <transformiix:result> with the text as a child |
[Throws] void {{domxref("XSLTProcessor.setParameter")}}({{jsxref("String")}} namespaceURI, {{jsxref("String")}} localName, any value)<xsl:param>.) A null value for namespaceURI is treated the same as an empty string.[Throws] any {{domxref("XSLTProcessor.getParameter")}}({{jsxref("String")}} namespaceURI, {{jsxref("String")}} localName)namespaceURI is treated the same as an empty string.[Throws] void {{domxref("XSLTProcessor.removeParameter")}}({{jsxref("String")}} namespaceURI, {{jsxref("String")}} localName)XSLTProcessor use the default value for the parameter as specified in the stylesheet. A null value for namespaceURI is treated the same as an empty string.void {{domxref("XSLTProcessor.clearParameters()")}}XSLTProcessor. The XSLTProcessor will then use the defaults specified in the XSLT stylesheet.void {{domxref("XSLTProcessor.reset()")}}XSLTProcessor.The following properties are [ChromeOnly] and not exposed to Web content:
[ChromeOnly] attribute unsigned long {{domxref("XSLTProcessor.flags")}}Flags that tweak the behavior of the processor. Not reset by calling {{domxref("XSLTProcessor.reset()")}}. Default value: 0
Possible values are:
| Name | Value | Effect |
|---|---|---|
| (None) | 0 |
None |
DISABLE_ALL_LOADS |
1 |
Disable loading external documents (via e.g. <xsl:import> and document()) |
Not part of any specification. This is a proprietary interface that originated in Gecko.
{{ Source("dom/webidl/XSLTProcessor.webidl", "XSLTProcessor.webidl") }}{{ Source("dom/xslt/nsIXSLTProcessor.idl", "nsIXSLTProcessor.idl") }}{{Compat("api.XSLTProcessor")}}