XML XSLT Transformation
CV-95Paste an XML document and an XSLT stylesheet, separated by a line with only =====, and see the transformed output. It uses an XSLT 1.0 engine written in JavaScript, so the result is the same in every browser.
Runs in your browser. Nothing is uploaded.
XML, then a line with only =====, then the XSLT stylesheet
Result
How to use it
- Paste the XML first, then a line with only =====, then the XSLT stylesheet.
- Check that the stylesheet starts with xsl:stylesheet or xsl:transform and declares the xsl namespace.
- Click Transform.
- Copy the result. If your stylesheet uses xsl:output method="text", you get plain text.
What runs the transformation
The transformation is done by an XSLT 1.0 engine written in JavaScript that runs in the page, so the result is the same in every browser. Some browsers have removed their built-in XSLT, which is why this tool does not rely on it. It implements XSLT 1.0 with XPath 1.0, so features from XSLT 2.0 and 3.0, such as xsl:for-each-group or regular expression functions, are not supported. The engine is a separate download that loads only when you open this tool. Check the result in the program that will use the stylesheet in production, because processors can differ on edge cases.
What is refused
The XML and the stylesheet must both be well-formed, and the stylesheet root must be xsl:stylesheet or xsl:transform in the namespace http://www.w3.org/1999/XSL/Transform. A stylesheet that uses xsl:import, xsl:include or the document() function is refused, because they load other files and this page makes no requests. Paste a combined stylesheet instead. The result has no XML declaration.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Nothing below =====. Put the XSLT stylesheet there. | The separator is present but there is no stylesheet after it. | Paste the stylesheet below the line with =====. |
The stylesheet uses document(), which loads another file. Nothing is fetched here, so remove it or paste the data into the XML. | The stylesheet calls the XSLT document() function. | Remove the call or put the data in the XML input. |
Questions people ask
How do I apply an XSLT stylesheet to XML online?
Paste the XML, a line with only =====, and the stylesheet into the box, then click Transform. The transformed output appears on the right. Nothing leaves your browser.
Which XSLT version does it support?
XSLT 1.0 with XPath 1.0, run by an engine written in JavaScript. XSLT 2.0 and 3.0 stylesheets that depend on newer functions or grouping will fail or give different results.
Why does the output have no XML declaration?
The engine writes the result without an XML declaration, and omit-xml-declaration is not applied. Indentation follows indent="yes" on xsl:output. Add a declaration to the copied output yourself if you need one.
How do I get plain text output?
Put <xsl:output method="text"/> in the stylesheet. The tool then returns the plain text of the result, with characters such as & and < written as they are. Without it the result is shown as serialized XML or HTML.
Why was my xsl:include refused?
xsl:include and xsl:import would load another file, and the tool does not make any file or network requests. Copy the included templates into one stylesheet and paste that.
Is my XML sent to a server?
No. Both parts are parsed and transformed in your browser tab and are not stored or uploaded. Parsing and transformation happen inside the browser, and nothing is saved between visits except your options.
About this tool
Uses the open-source xslt-processor library (LGPL-3.0, github.com/DesignLiquido/xslt-processor), an XSLT 1.0 engine written in JavaScript that runs in the page, so the result is the same in every browser, including those that have removed their built-in XSLT. XSLT 2.0 and 3.0 features are not supported. The engine is loaded only when you open this tool. Known gap: position() inside a template called by xsl:apply-templates may return 1 instead of the real position; xsl:for-each and xsl:number are fine. Both parts must be well-formed XML, and the stylesheet root must be xsl:stylesheet or xsl:transform. A stylesheet that uses xsl:import, xsl:include or document() is refused, because those load other files and nothing is fetched here. If the stylesheet sets xsl:output method="text" you get the plain text; otherwise the result is the serialized XML or HTML, indented if xsl:output says indent="yes", and without an XML declaration. The stylesheet is run against what you paste and not saved anywhere.