xslt
Transform XML document using XSLT engine
Syntax
result = xslt(source,style,dest)
[result,transformer] = xslt(___)
xslt(___,'-web')
xslt(___,XMLEngine=xmlengine)
Description
result = xslt(source,style,dest)
transforms an XML
document using a stylesheet and returns the resulting document's URL. The function uses
these inputs, the first of which is required:
source
is the filename or URL of the source XML file, specified as a character vector or string scalar.source
can also specify a DOM node.style
is the filename or URL of an XSL stylesheet, specified as a character vector or string scalar.dest
is the filename of the desired output document, specified as a character vector or string scalar. Ifdest
is absent or empty, the function uses a temporary filename. Ifdest
is'-tostring'
, the function returns the output document as a character vector.
source
and style
can be located in
the current folder, a folder on the MATLAB® path, a folder outside the MATLAB path specified with a full or relative pathname, an internet URL with
protocol type "http://"
or "https://"
, or a remote
location. For more information on remote locations, see Work with Remote Data.
[result,transformer] = xslt(___)
returns
a JAXP transformer object based on the provided XSL stylesheet. The JAXP transformer
object can be passed to subsequent xslt
calls as
style
.
xslt(___,'-web')
displays the resulting
document in the HTML Viewer.
xslt(___,XMLEngine=xmlengine)
uses the specified XSLT processing engine to transform an
XML document. (since R2025a) You can specify xmlengine
as one of these values:
"auto"
– The default value. If no Java elements are detected, process the XML document using the MATLAB API for XML Processing."maxp"
– Process the XML document using the MATLAB API for XML Processing."jaxp"
– Process the XML document using the JAVA API for XML Processing.
Examples
This example converts the file info.xml
using the stylesheet
info.xsl
, writing the output to the file
info.html
. It launches the resulting HTML file in the HTML
Viewer.
xslt('info.xml', 'info.xsl', 'info.html', '-web')
Tips
MATLAB uses the Saxon XSLT processor, version 6.5.5, which supports XSLT 1.0 expressions. For more information, see About SAXON.
For additional information on writing XSL stylesheets, see the World Wide Web Consortium (W3C®) web site, The Extensible Stylesheet Language Family (XSL).