XSLT Transformer with an XPath Tester
Operator: Abdulla Al Fahad. How tools are built and checked
A stylesheet that works on the three-line sample fails on the real feed, and the browser console says nothing useful. Here you paste the XML and the XSLT side by side, press Run transform, and see the output as text, with stylesheet parameters you can change between runs and an XPath tester that highlights the matches inside your document.
The transform runs on your browser's own XSLTProcessor when it has one. Chrome 155, on the stable channel from 17 November 2026, removes it (developer.chrome.com/docs/web-platform/deprecating-xslt); an origin trial and an enterprise policy keep it until Chrome 164 in August 2027. In a browser without it, the page loads xslt-polyfill, libxslt compiled to WebAssembly, the first time you press Run transform, and every result says which engine produced it. Either way it is XSLT 1.0 and XPath 1.0, and stylesheets that would make the processor fetch another file are refused before anything runs.
Key features
- Runs an XSLT 1.0 stylesheet on the browser's XSLTProcessor, or on a built-in libxslt (WebAssembly, about 1.5 MB, loaded only when the browser has none), with text parameters for each xsl:param
- Names the engine that ran, "your browser's XSLT engine" or "built-in libxslt (WebAssembly)", next to every result
- XPath 1.0 tester that returns node-sets, strings, numbers or booleans, with namespace prefixes picked up from the document
- Matched nodes listed with their path and highlighted in a re-indented copy of the source
What the transformer accepts and refuses
The output method comes from the stylesheet: xsl:output method="text" gives plain text, "html" gives markup, and the default is XML with an XML declaration unless omit-xml-declaration is yes. HTML and XML output is shown and downloaded as source text only; it is built in a detached, inert document and never rendered, so a script or image tag in the result does nothing. Inputs are capped at 2 million characters each. Parameter values are always strings, so a numeric parameter is compared with number($p) inside the stylesheet.
How it works
Before anything runs, both texts are checked, and the same checks apply to both engines. Any <!ENTITY declaration is refused, which closes both external-entity reads and entity-expansion bombs, and so is a DOCTYPE that names an external DTD or carries an internal subset; a plain <!DOCTYPE name> is fine. These checks read the raw text, comments and processing instructions included, so nothing can be hidden in them. The stylesheet is then parsed and every element and attribute value is inspected, however large it is. It is refused if any attribute (select, test, match, use, a sort key, an attribute value template) contains a call to document(), including a call written with character references, if any element in the XSLT namespace is xsl:import, xsl:include or xsl:document whatever prefix it uses, or if it contains msxsl:script or exsl:document. Declaring the EXSLT dynamic namespace is refused too, because dyn:evaluate can build a document() call from strings at run time.
The WebAssembly engine fetches imports and document() targets by itself, so it gets a second lock: while a transform runs, fetch and XMLHttpRequest are replaced by functions that refuse, and any attempt turns the result into an error. The engine is chosen after the checks pass. XPath expressions run through document.evaluate against the parsed source, which is a separate API from XSLTProcessor and is not part of the Chrome removal; a default namespace has no prefix in XPath 1.0, so the page offers it as default, and you can add or override any prefix as prefix=uri.
Common use cases
- An integrator keeps one stylesheet and changes the status parameter: shipped gives "Ada Lovelace: 2 lines, 3 units" and open gives "Grace Hopper: 1 lines, 10 units", which confirms the filter before it goes into a pipeline.
- A developer debugging a missing node tries //item, //order/item and //default:item against a feed with a default namespace, and finds that only the prefixed form matches.
How to use this tool
- Paste or open the source XML and the stylesheet, or press Load example.
- Add a parameter for each xsl:param you want to set, then press Run transform.
- Switch to the XPath tester, type an expression and press Evaluate to see and highlight the matches.
Example
Load example: the source XML and stylesheet are pasted as written, with the parameter status = open and the XPath //order[@status='open']/item
<orders xmlns:ex="urn:example:shop">
<order id="1001" status="shipped">
<customer>Ada Lovelace</customer>
<item sku="K-1" qty="2" price="4.50"/>
<item sku="M-9" qty="1" price="19.00"/>
</order>
<order id="1002" status="open">
<customer>Grace Hopper</customer>
<item sku="K-1" qty="10" price="4.50"/>
</order>
</orders>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:param name="status" select="'shipped'"/>
<xsl:template match="/orders">
<xsl:for-each select="order[@status = $status]">
<xsl:value-of select="customer"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="count(item)"/>
<xsl:text> lines, </xsl:text>
<xsl:value-of select="sum(item/@qty)"/>
<xsl:text> units </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>Transform output (the stylesheet writes the count and then the fixed words " lines, ", so one item reads "1 lines"), the engine line, and the XPath result
Grace Hopper: 1 lines, 10 units
Engine: your browser's XSLT engine, or built-in libxslt (WebAssembly) where the browser has none
XPath: 1 node matched
1 element /orders/order[2]/itemCommon pitfalls
Chrome 155 removes XSLTProcessor from the stable channel on 17 November 2026, and Mozilla and WebKit have signalled support for removing it too. This page does not depend on that: when the browser has no processor, the transform runs on the built-in WebAssembly libxslt, which adds about 1.5 MB on first use. With either engine XSLT runs on the page's main thread and cannot be cancelled, so a huge document or a runaway template recursion can freeze the tab until it finishes. A Content Security Policy that blocks WebAssembly compilation would stop it, and the page then says so.
XSLT 2.0 and 3.0 features such as xsl:for-each-group, regular expressions and format-date are not available, because the browser engine implements 1.0.
The highlighted source is a re-indented rendering made from the parsed document, so its line numbers are not those of the file you pasted.
- Test a predicate in the XPath tab first: sum(//item/@qty) returns 13 as a number for the example, which confirms the attribute path before you build an xsl:for-each around it.
- If an expression uses a prefix the source never declares, add it in the box as prefix=uri with the URI copied from the xmlns attribute; prefixes from the stylesheet are not shared with the tester.
Common errors and how to fix them
- "The stylesheet calls document(). That function loads other documents by URL, so it is refused here"
- Put the data the stylesheet needs into the source XML, or pass it as a parameter. Nothing in this tool makes network requests, and the same rule applies to xsl:import and xsl:include, which fetch files.
- "This browser has no XSLTProcessor and the built-in WebAssembly fallback could not start"
- The fallback is loaded on demand and compiled in the page, so a Content Security Policy without 'wasm-unsafe-eval', or a first run while offline, stops it. Use a browser that still has XSLTProcessor, or allow WebAssembly for the page; the XPath tester works without either.
- "The source XML declares an entity (<!ENTITY ...>)"
- Entity declarations are refused in the source and in the stylesheet. Remove the DTD and write the characters out.
- "The source XML is not well-formed XML: ..."
- The browser's parser message follows. Unclosed tags, an unescaped & and a second root element are the usual causes; the message includes a line and column.
- "The transform failed ... Browsers report few details"
- The engine rejected the stylesheet or hit a runtime error. Check that the root is xsl:stylesheet or xsl:transform in the http://www.w3.org/1999/XSL/Transform namespace and that every select expression is valid XPath 1.0.
Best practices
- Include a record with an optional element missing in your test XML. A template that selects it returns an empty string rather than an error, and that quiet gap is the case real feeds eventually hit.
Why these stylesheets are refused
document('http://...') makes the processor download a file chosen by whoever wrote the stylesheet, and xsl:import and xsl:include do the same for stylesheets. A page that promises nothing leaves your browser cannot let a pasted stylesheet reach out, so these constructs are blocked rather than sandboxed.
Entity declarations are refused for XML as well as for stylesheets. An external entity can name a file or a URL, and a nested chain of internal ones can expand to gigabytes. Rewriting such a document without its DTD, with the characters written out, is the safe way to test it here.
Frequently asked questions
Will a stylesheet give the same result after my browser drops XSLTProcessor?
It should, because Chrome's own processor is libxslt as well and the fallback is libxslt compiled to WebAssembly. Both implement XSLT 1.0 only. The result line names the engine, so if an output ever differs between two browsers you can see which engine produced each one.