XSLT Tester
Paste an XML document and an XSLT 1.0 stylesheet to transform it instantly. See the result as a rendered HTML preview or as formatted source, set stylesheet parameters, and get clear hints when something is wrong. Everything runs locally with your browser's built-in XSLT processor.
Last updated:
Uses the XSLT 1.0 processor built into your browser (XSLTProcessor). Your XML and stylesheet never leave this page; the preview runs in a sandbox with scripts disabled.
How to use the XSLT Tester
- Pick an example from the list to start, or paste your own XML document into the left box and your XSLT stylesheet into the right box. You can also open files from your device.
- Watch the output update as you type. With Live transform off, press Transform XML or Ctrl+Enter.
- Set parameters: every top-level xsl:param in your stylesheet gets an input box; type a value to override its default.
- Switch views between Preview (rendered HTML or formatted text) and Output source (the exact markup or text produced).
- Fix any problems using the message above the output: it shows parse errors by line and column and points to XPath or XSLT 2.0 mistakes.
- Copy or download the result when it looks right.
How an XSLT stylesheet works
An XSLT processor reads the source XML into a tree and starts at the root node. It looks for the template whose match pattern fits that node best and runs it. Inside a template, literal elements such as <tr> are copied to the output, while instructions in the xsl: namespace compute content: xsl:value-of outputs the string value of an XPath expression, xsl:for-each loops, and xsl:apply-templates hands child nodes back to the processor so their own templates run. When no template matches, the built-in rules copy text and keep walking down the tree, which is why an almost-empty stylesheet still outputs all the text of a document.
Attribute values written in curly braces, like <item sku="{@id}">, are attribute value templates: the XPath inside the braces is evaluated and inserted. Inside an XSLT file, a less-than comparison must be written as < because the stylesheet is XML too: test="price < 20".
Which engine runs your stylesheet
Most browsers have shipped a native XSLT 1.0 processor (libxslt in Chrome and Safari, TransforMiix in Firefox), exposed to web pages as XSLTProcessor. Browser vendors are now phasing it out, so this tester checks for it first and, if it is missing, loads xslt-processor, an open-source XSLT 1.0 implementation in pure JavaScript, from a CDN the first time you transform. The message above the output says which engine was used. Results are the same for everyday stylesheets; rarely used features (some xsl:number formats, extension functions, exact whitespace handling) may differ, so check edge cases with a command-line processor like xsltproc before relying on them in production.
XSLT 1.0 instruction reference
| Instruction | What it does | Example |
|---|---|---|
xsl:template | Rule for nodes matching a pattern, or a named reusable block | <xsl:template match="book"> |
xsl:apply-templates | Process selected nodes with their matching templates | <xsl:apply-templates select="book"/> |
xsl:value-of | Output the string value of an expression | <xsl:value-of select="title"/> |
xsl:for-each | Loop over a node-set (can contain xsl:sort) | <xsl:for-each select="//book"> |
xsl:sort | Sort a loop or apply-templates; text or number, ascending or descending | <xsl:sort select="price" data-type="number"/> |
xsl:if | Output content when a test is true (no else branch) | <xsl:if test="stock = 0"> |
xsl:choose / when / otherwise | If / else-if / else | <xsl:when test="@lang='fr'"> |
xsl:variable, xsl:param | Bind a value (variables cannot be changed later); params can be overridden | <xsl:variable name="n" select="count(book)"/> |
xsl:call-template | Call a named template, often recursively, with xsl:with-param | <xsl:call-template name="esc"/> |
xsl:copy, xsl:copy-of | Shallow copy of the current node / deep copy of a node-set | <xsl:copy-of select="author"/> |
xsl:element, xsl:attribute | Create an element or attribute with a computed name or value | <xsl:attribute name="class"> |
xsl:key | Index nodes for fast lookup with key() and for grouping | <xsl:key name="k" match="book" use="@category"/> |
xsl:number | Insert a formatted sequence number (1, a, A, i, 01…) | <xsl:number format="1."/> |
xsl:output | Choose html, xml or text output, indentation, declaration | <xsl:output method="text"/> |
Common patterns and tips
- Identity transform: a template matching
@* | node()that doesxsl:copyand applies templates to its children copies the whole document. Add more specific templates to rename, remove or change just a few nodes (see the "Restructure XML" example). - Grouping in XSLT 1.0: define
xsl:keyon the grouping value and loop over nodes wheregenerate-id() = generate-id(key('k', @category)[1]), the first node of each group. This is the Muenchian method. - Numbers as text:
xsl:sortsorts alphabetically unless you adddata-type="number"; otherwise 100 sorts before 20. - Whitespace: use
xsl:textfor exact text and newlines ( ) in text output, andxsl:strip-space elements="*"to drop indentation-only text nodes from the source. - Formatting numbers:
format-number(1234.5, '#,##0.00')gives 1,234.50. - Default namespaces: XPath 1.0 has no default element namespace, so declare a prefix for namespaced XML and use it in every pattern and select.
Frequently asked questions
What is XSLT?
XSLT (Extensible Stylesheet Language Transformations) is a W3C language for transforming XML documents into other XML, HTML or plain text. A stylesheet is itself an XML document made of templates: each xsl:template matches nodes with an XPath pattern and describes what to output for them. It is widely used for turning data feeds into web pages, converting between XML formats, and generating reports.
Which XSLT version does this tester support?
XSLT 1.0 with XPath 1.0, which is what the XSLT processor built into web browsers implements. XSLT 2.0 and 3.0 features such as xsl:for-each-group, xsl:function, regular expressions, lower-case() or format-date() are not available. The tester flags these and suggests XSLT 1.0 alternatives, for example Muenchian grouping with xsl:key instead of xsl:for-each-group.
Does it work in browsers without built-in XSLT?
Yes. Browser makers are phasing out the native XSLTProcessor, and Chrome has announced its removal. When the built-in engine is missing, the tester automatically downloads xslt-processor, an open-source XSLT 1.0 engine written in JavaScript, and runs your stylesheet with it. That engine covers the common XSLT 1.0 instructions and XPath functions and reports error messages, while the native engines fail silently; for those, the tester lists likely causes such as an undeclared variable or invalid XPath.
Why is my output empty or just plain text?
The most common cause is a namespace mismatch: if the XML has a default namespace (xmlns="…"), match="book" will not match it. Declare the same namespace URI with a prefix in the stylesheet, for example xmlns:b="…", and match b:book. Another cause is the built-in template rules: when no template matches, XSLT copies only the text of elements, so the output looks like run-together text.
How do I pass parameters to the stylesheet?
Declare them at the top level with xsl:param, for example <xsl:param name="minPrice" select="0"/>. The tester creates an input box for each one. A typed value is passed as a string, just like most command-line processors do; use number($minPrice) when you need to compare it numerically. Leave the box empty to use the default.
What is the difference between output methods html, xml and text?
method="xml" writes well-formed XML with an optional XML declaration. method="html" writes HTML, so empty elements like br are not self-closed and special characters are handled the HTML way. method="text" writes only the string value of the result with no markup or escaping, which is how you produce CSV, JSON or plain-text reports. Without xsl:output, the method is html when the first output element is <html>, otherwise xml.
Is my XML uploaded anywhere?
No. Parsing and transformation happen in this page, using your browser's own XSLT engine or the JavaScript fallback engine (only the engine's code is downloaded, never your data), so your documents never leave your device. The HTML preview is shown in a sandboxed frame with scripts disabled. External files referenced through xsl:include, xsl:import or document() are not fetched.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.