What is the XSL file format?
An .xsl file is an XSLT stylesheet - a plain-text XML document that contains transformation rules written in the XSLT language. XSLT (Extensible Stylesheet Language Transformations) was standardized by the W3C in November 1999; the current version, XSLT 3.0, arrived in 2017. The stylesheet is not data and not a finished document: it is a program that an XSLT processor applies to an input XML file to produce HTML, plain text, or another XML output.
Inside an .xsl file, the root element is <xsl:stylesheet> or <xsl:transform>, declared in the namespace http://www.w3.org/1999/XSL/Transform. Template rules (<xsl:template match="...">) select nodes from the source tree; output instructions such as <xsl:value-of>, <xsl:for-each>, and <xsl:apply-templates> build the result. The version attribute on the root element - 1.0, 2.0, or 3.0 - tells the processor which language level to apply.
.xsl and .xslt refer to the same kind of file; .xsl is the older, XSLT 1.0-era spelling, while .xslt became more common with XSLT 2.0 and 3.0. Historically the .xsl extension also covered XSL-FO (formatting objects for PDF output), a separate branch of the XSL family now associated with .fo files.
Common uses include converting XML data feeds to readable web pages, transforming configuration files between schemas, and generating PDFs via XSL-FO processors such as Apache FOP.
Security & safety
RISK: LOWAn .xsl is plain-text XML and contains no compiled code, so reading or editing one is safe. The realistic risks are at the PROCESSOR when running an UNTRUSTED stylesheet/input: XSLT 2.0/3.0 and some extension functions can read/write files or make network calls (document(), unparsed-text(), extension functions), and XML processing can be hit by XXE/ entity-expansion attacks. So don't run stylesheets from untrusted sources with extensions/ external entities enabled. For an end user just opening an .xsl to read it, there's no danger.
Format details
in a nutshellPrograms that open XSL files
Technical details
deep spec| MIME type | application/xslt+xml (also accepted: text/xsl, application/xml, text/xml) |
| File encoding | UTF-8 by default; UTF-16 and other XML-declared encodings are permitted; a UTF-8 BOM (EF BB BF) may precede the XML declaration |
| Container format | Well-formed XML document |
| Root element | <xsl:stylesheet> or <xsl:transform> in the namespace http://www.w3.org/1999/XSL/Transform |
| Version signaling | version attribute on the root element: 1.0, 2.0, or 3.0 - selects the XSLT language level the processor applies |
| File signature (magic bytes) | 3C 3F 78 6D 6C ("<?xml") at offset 0; definitive identity requires the XSLT root element and namespace, not a fixed magic number |
| Typical file size | 1 KB - 200 KB; large enterprise stylesheets may be larger |
| Output modes | HTML, XHTML, plain text, or XML - selected via the <xsl:output method="..."> declaration inside the stylesheet |
| Core instruction elements | <xsl:template>, <xsl:apply-templates>, <xsl:for-each>, <xsl:value-of>, <xsl:if>, <xsl:choose>, <xsl:call-template> |
| XPath dependency | Uses XPath expressions to address and select nodes: XPath 1.0 with XSLT 1.0, XPath 2.0 with XSLT 2.0, XPath 3.1 with XSLT 3.0 |
| Namespace URI | http://www.w3.org/1999/XSL/Transform (conventionally bound to the prefix xsl:) |
| Compression | None built-in; plain text, may be served gzip-compressed at the HTTP transport level |
| Processor support | xsltproc (libxslt), Saxon (2.0/3.0), Xalan-C/J, MSXML, .NET XslCompiledTransform, built-in browser engines (XSLT 1.0) |
| Platform support | Cross-platform: Windows, macOS, Linux, and any environment with a conforming XSLT processor |
| Standards body | W3C (World Wide Web Consortium) |
| Released | 1999 (XSLT 1.0, W3C Recommendation, November 16, 1999) |
| Latest version | XSLT 3.0 (W3C Recommendation, June 8, 2017) |
| Open standard | Yes · royalty-free |
| Specification | www.w3.org |
XSL conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about XSL files.