Home › Developer Tools › XSLT Tester

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.

Advertisement
Advertisement

How to use the XSLT Tester

  1. 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.
  2. Watch the output update as you type. With Live transform off, press Transform XML or Ctrl+Enter.
  3. Set parameters: every top-level xsl:param in your stylesheet gets an input box; type a value to override its default.
  4. Switch views between Preview (rendered HTML or formatted text) and Output source (the exact markup or text produced).
  5. 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.
  6. 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 &lt; because the stylesheet is XML too: test="price &lt; 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

InstructionWhat it doesExample
xsl:templateRule for nodes matching a pattern, or a named reusable block<xsl:template match="book">
xsl:apply-templatesProcess selected nodes with their matching templates<xsl:apply-templates select="book"/>
xsl:value-ofOutput the string value of an expression<xsl:value-of select="title"/>
xsl:for-eachLoop over a node-set (can contain xsl:sort)<xsl:for-each select="//book">
xsl:sortSort a loop or apply-templates; text or number, ascending or descending<xsl:sort select="price" data-type="number"/>
xsl:ifOutput content when a test is true (no else branch)<xsl:if test="stock = 0">
xsl:choose / when / otherwiseIf / else-if / else<xsl:when test="@lang='fr'">
xsl:variable, xsl:paramBind a value (variables cannot be changed later); params can be overridden<xsl:variable name="n" select="count(book)"/>
xsl:call-templateCall a named template, often recursively, with xsl:with-param<xsl:call-template name="esc"/>
xsl:copy, xsl:copy-ofShallow copy of the current node / deep copy of a node-set<xsl:copy-of select="author"/>
xsl:element, xsl:attributeCreate an element or attribute with a computed name or value<xsl:attribute name="class">
xsl:keyIndex nodes for fast lookup with key() and for grouping<xsl:key name="k" match="book" use="@category"/>
xsl:numberInsert a formatted sequence number (1, a, A, i, 01…)<xsl:number format="1."/>
xsl:outputChoose html, xml or text output, indentation, declaration<xsl:output method="text"/>

Common patterns and tips

  • Identity transform: a template matching @* | node() that does xsl:copy and 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:key on the grouping value and loop over nodes where generate-id() = generate-id(key('k', @category)[1]), the first node of each group. This is the Muenchian method.
  • Numbers as text: xsl:sort sorts alphabetically unless you add data-type="number"; otherwise 100 sorts before 20.
  • Whitespace: use xsl:text for exact text and newlines (&#10;) in text output, and xsl: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.

Related tools

XPath TesterTest XPath expressions on XML or HTML: highlighted matches, node paths, values and examples.XML FormatterBeautify, validate and minify XML with a collapsible tree view.XML ValidatorCheck if XML is well-formed, see the exact line and column of each error and pretty-print it.XML to JSONConvert XML to JSON with validation.Online Python CompilerRun Python 3 in your browser with input(), numpy, pandas, charts and share links.JSON EditorEdit JSON in a tree and as code side by side: add, rename, drag, change types, undo and download.Unzip FilesOpen and extract ZIP files online.RAR & 7z ExtractorOpen RAR, 7z and other archives online and extract files.Regex TesterTest and debug regular expressions live.File Info ViewerCheck file size, type, date and MD5/SHA hashes.SQLite ViewerOpen .db and .sqlite files in your browser, browse tables and run SQL queries.DOCX ViewerOpen and read Word .docx files in your browser, then print or save them as HTML.EPUB ReaderOpen and read EPUB e-books in your browser with pages, a table of contents and font controls.What Is My BrowserSee your browser, version, OS, engine, screen and which web features it supports.Font ViewerPreview TTF, OTF, WOFF and WOFF2 fonts with sample text, waterfall, glyphs and metadata.Markdown EditorWrite Markdown with a toolbar, live split preview, autosave and .md or HTML export.Regex Cheat Sheet75+ ready-to-use regex patterns for emails, URLs, IPs and dates, each with a live test box.JavaScript Keycode FinderPress any key to see its JavaScript key, code, keyCode, which, location and modifiers.QR Code ScannerScan QR codes with your camera or from an image and safely read the link or text.RAID CalculatorUsable capacity, efficiency and fault tolerance for RAID 0, 1, 5, 6, 10, 50 and 60 arrays.JSONPath TesterTest JSONPath expressions live: filters, slices, wildcards and recursive search, with matches highlighted.Mermaid Diagram EditorWrite Mermaid code and see flowcharts, sequence, Gantt and ER diagrams live. Export SVG or PNG.Country Codes ListSearch ISO 3166 alpha-2, alpha-3 and numeric country codes with calling codes and TLDs.CSS Selector TesterTest CSS selectors on your HTML: highlighted matches, match count and specificity.Git Cheat SheetSearchable Git command reference by task, with copy buttons and an undo/rename/fix wizard.HAR File ViewerOpen a .har file to see a waterfall timeline, headers, bodies, timings and size totals.jq PlaygroundRun jq filters on JSON in your browser with live output, flags and an example library.Markdown Cheat SheetInteractive Markdown syntax reference: edit every example and see the live rendered preview.Regex ExplainerPaste a regular expression and get a plain-English breakdown, railroad diagram and flag notes.EML File ViewerOpen .eml email files to read the message, headers and raw source and save attachments.Graphviz Online ViewerWrite Graphviz DOT code and render graphs live; switch layout engines, export SVG or PNG.JavaScript Online CompilerWrite and run JavaScript in your browser with a console, timing, error lines and share links.Jupyter Notebook ViewerOpen .ipynb files and read code, Markdown, math, tables, plots and errors without Python.LaTeX Table GeneratorEdit a table like a spreadsheet or paste from Excel and get LaTeX tabular or booktabs code.Log File ViewerOpen huge log files with level colors, regex and time filters, JSON pretty-print and tail -f.Logic Gate SimulatorBuild logic circuits with AND, OR, NOT, XOR gates and flip-flops; see live outputs and truth tables.MSG File ViewerOpen Outlook .msg emails in your browser: sender, recipients, body, headers and attachments.Online Code EditorVS Code-style editor in your browser: tabs, 50+ languages, find/replace, autosave.Online Hex EditorOpen any file as hex and ASCII, edit bytes, search, inspect values and save the result.PHP Online CompilerRun PHP 8 code in your browser with output, HTML preview, error lines and share links.PlantUML EditorWrite PlantUML and see sequence, class, activity and more diagrams live. Export SVG or PNG.Sorting Algorithm VisualizerWatch bubble, insertion, merge, quick, heap and radix sort step by step with live counters.Lottie ViewerOpen Lottie JSON or .lottie files to play, pause, scrub frames, change speed and see details.Diff ViewerPaste a git diff or .patch file and view it side by side or inline, with file navigation.EditorConfig GeneratorBuild an .editorconfig with indent, charset, line endings and trim rules per file pattern.Folder Compare ToolCompare two folders by file list, size and SHA-256 hash, then open a text diff of changed files.Glob Pattern TesterTest glob patterns like **/*.js, {a,b} and !exclusions against a list of file paths.JMESPath TesterEvaluate JMESPath expressions against JSON live, the query language used by the AWS CLI.MongoDB Query TesterTest MongoDB find filters, projections and aggregation pipelines on sample JSON documents.Semantic Version CalculatorBump, compare, sort and test SemVer versions against npm ^, ~ and x ranges.ASCII Diagram EditorDraw boxes, arrows and text on a character grid and copy plain-text diagrams for code and READMEs.DBF File ViewerOpen dBase .dbf files and shapefile tables, search and sort records, export CSV or XLSX.MBOX File ViewerOpen .mbox mail archives: list and search messages, read them, save attachments, export EML.MDB File ViewerOpen Access .mdb and .accdb databases in your browser: list tables, view rows, export CSV.Shapefile ViewerView zipped shapefiles on a map with the attribute table, then export to GeoJSON or CSV.
See all 53 Code Playgrounds & Testers →