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.
Syntax
The constructor has no parameters.
new XSLTProcessor()
Methods
[Throws] voidXSLTProcessor.importStylesheet(NodestyleSheet)- 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. [Throws]DocumentFragmentXSLTProcessor.transformToFragment(Nodesource,Documentowner)- Transforms the node source by applying the stylesheet imported using the
XSLTProcessor.importStylesheet()function. The owner document of the resulting document fragment is the owner node. [Throws]DocumentXSLTProcessor.transformToDocument(Nodesource)-
Transforms the node source applying the stylesheet given importing using the
XSLTProcessor.importStylesheet()function.The resultant object depends on the output method of the stylesheet:
Output method Result type htmlHTMLDocumentxmlXMLDocumenttextXMLDocumentwith a single root element<transformiix:result>with the text as a child [Throws] voidXSLTProcessor.setParameter(StringnamespaceURI,StringlocalName, any value)- Sets a parameter in the XSLT stylesheet that was imported. (Sets the value of an
<xsl:param>.) A null value fornamespaceURIis treated the same as an empty string. [Throws] anyXSLTProcessor.getParameter(StringnamespaceURI,StringlocalName)- Gets the value of a parameter from the XSLT stylesheet. A null value for
namespaceURIis treated the same as an empty string. [Throws] voidXSLTProcessor.removeParameter(StringnamespaceURI,StringlocalName)- Removes the parameter if it was previously set. This will make the
XSLTProcessoruse the default value for the parameter as specified in the stylesheet. A null value fornamespaceURIis treated the same as an empty string. voidXSLTProcessor.clearParameters()- Removes all set parameters from the
XSLTProcessor. TheXSLTProcessorwill then use the defaults specified in the XSLT stylesheet. voidXSLTProcessor.reset()- Removes all parameters and stylesheets from the
XSLTProcessor.
Properties
Non-Web-exposed properties
The following properties are [ChromeOnly] and not exposed to Web content:
[ChromeOnly] attribute unsigned longXSLTProcessor.flags-
Flags that tweak the behavior of the processor. Not reset by calling
XSLTProcessor.reset(). Default value:0Possible values are:
Name Value Effect (None) 0None DISABLE_ALL_LOADS1Disable loading external documents (via e.g. <xsl:import>anddocument())
Examples
Specifications
Not part of any specification. This is a proprietary interface that originated in Gecko.
Gecko IDL
Browser compatibility
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Microsoft Edge | Opera | Safari |
|---|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | (Yes) | No support | (Yes) | (Yes) | (Yes) |
| Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | ? | (Yes) | ? | ? | ? | ? |