W3cubDocs

/Web APIs

XSLTProcessor: transformToDocument() method

The transformToDocument() method of the XSLTProcessor interface transforms the provided Node source to a Document using the XSLT stylesheet associated with XSLTProcessor.

Syntax

js

transformToDocument(source)

Parameters

source

The Node source to apply the XSLT stylesheet to.

Return value

A Document. The actual interface depends on the output method of the stylesheet:

Output method Result interface
html HTMLDocument
xml XMLDocument
text XMLDocument with a single root element <transformiix:result> with the text as a child

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
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.

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/transformToDocument