XSLT (Extensible Stylesheet Language Transformations) is a transformation language for XML designed to transform structured documents into other formats (such as XML, HTML, and plain text, or, in XSLT 3, JSON). Questions should use one of the xslt-1.0, xslt-2.0, or xslt-3.0 tags as appropriate.
XSLT
News: As of June the 8th, 2017, XSLT 3.0 is a Recommendation of the W3C Consortium
Extensible Stylesheet Language Transformations (XSLT) is a programming language for transforming XML documents into other XML documents, text documents, or HTML documents. Other output formats are possible (e.g., PDF transformations using XSL-FO).
The original document is not changed; rather, a new document is created based on the content of an existing one. Typically, input documents are XML files, but anything from which the processor can build an XQuery and XPath Data Model can be used, for example, relational database tables, or geographical information systems.
A typical transformation is accomplished as follows:
- A stylesheet is created (typically a
.xsl
file). - An XML data source is created (such as a
.xml
file). - The XSLT processor is loaded with both the XSL and XML content.
- The XML document is parsed into an XPath Data Model (XDM) tree (XDM is similar to DOM).
- The XDM tree is traversed to produce a resulting document.
XSLT syntax is based on XML, which means that XSL documents also are well-formed XML documents. XSLT, with a heavy emphasis on recursion, borrows principles from functional languages, including declarative programming, pattern matching, and immutable variables.
As XSL is written in an XML format, its verbosity does not make it the first choice for general-purpose programming. When used correctly, XSL transformations produce elegant solutions to complex problems that are harder to solve in imperative languages.
XSLT Processors and Libraries
XSLT 3.0 processors
XSLT 3.0 processors are backward compatible with XSLT 2.0 and usually XSLT 1.0 as well
- Saxon provides free and commercial XSLT 1.0, 2.0 and 3.0 command line processors and libraries
- Raptor XML is Altova's XML and XBRL processor, which as of 2017 supports XSLT 1.0, 2.0 and XSLT 3.0 except streaming. A free command line version used to exist but is no longer available for download.
XSLT 2.0 processors
Backward compatibility with XSLT 1.0 is optional, but most processors support this
- Saxon and Raptor XML listed above support XSLT 2.0 as well
- QtXmlPatterns is a library to use XSLT 2.0 with Qt for C++, but is considered experimental by its creators
- xmlpatterns is a C++ commandline utility using Qt to run XSLT 2.0 or XQuery
- gexslt Gobo XSLT 2.0 an XSLT 2.0 processor written in Eiffel, seems to be discontinued, but supports almost all of XPath 2.0 and most of XSLT 2.0. Comes as commandline processor or Eiffel library.
- jd.xslt is a Java implementation of XSLT 1.1 (the spec was withdrawn in favor of 2.0 but already has a lot of 2.0 features)
- SOA Expressway XSLT is Intel's XSLT 2.0 processor as part of SOA Expressway, separate download no longer available, except via Wayback Machine
- PsychoPath supports XPath 2.0 to be used within Eclipse with XSLT
- XSLT 2.0 extension for Xerces, partially implemented but seems to be discontinued
- Gestalt, an XSLT 2.0 processor which formed the basis for gexslt
- IBM XML Feature Pack for WebSphere supports XSLT 2.0, XPath 2.0 and XQuery 1.0
- MarkLogic is an XML database which includes its own XSLT 2.0 processor
- XMLPrime provides an XSLT 2.0 processor for the .NET platform
XSLT 1.0 processors
An incomplete list of known and lesser known XSLT 1.0 processors:
- XT, the very first XSLT 1.0 processor by James Clark, still available for download
- Xalan-Java is a free XSLT 1.0 processor for Java
- Xalan-C is a free XSLT 1.0 processor for C++
- System.Xml.Xsl contains Microsoft's managed .NET XSLT 1.0 processor
- MSXML contains Microsoft's native ActiveX XSLT 1.0 processor, used in versions of Internet Explorer
- xsltc is a commandline processor to create compiled .NET assemblies for XSLT 1.0 transformations, not to be confused with Xalan's xsltc
- xsltproc or libxslt is a C library for XSLT 1.0 for the GNOME project, this version is used by PHP and other languages that compile to C
- TransforMiiX is Mozilla Firefox's XSLT 1.0 processor, of which a stand-alone version can be build.
- Sablotron an XSLT 1.0 processor written in C++
- Minoru XSL or MDC-XSL an XSLT 1.0 processor written in C++, seems to be abandoned
- Xsltp.pl, an XSLT 1.0 compliant processor written natively in Perl
- XML::XSLT a Perl module with a partial complete XSLT 1.0 processor
- CFX XSLT open source XSLT 1.0 processor for ColdFusion
- XSLJIT by DataPower, a hardware accelerated XSLT processor, now used in WebSphere with XA35
JavaScript XSLT 2.0 processors
These processors enable XSLT 2.0 in the browser.
- Frameless is a light-weight, partial XSLT 2.0 implementation of XSLT in JavaScript for use in the browser
- Saxon CE is Saxon's XSLT 2.0 processor cross-compiled to JavaScript for use in the browser
- XSLTy is a command line version of Saxon-CE and supports XSLT 2.0; it requires PhantomJS
- jQuery XPath 2.0 plugin, while not an XSLT processor, it enables the use of XPath 2.0 from within jQuery, and therefore from within the browser, which is of interest to a large group of users.
JavaScript XSLT 3.0 processors
These processors enable XSLT 3.0 in the browser.
- Saxon-JS effectively supersedes Saxon-CE. It is an XSLT 3.0 run-time written in pure JavaScript. It executes stylesheets that must be compiled by Saxon-EE directly, or from within an environment such as the oXygen XML editor that includes Saxon-EE.
JavaScript wrappers for XSLT 1.0 in the browser
- JAXP is the Java API for XML, required when doing transformations in Java through the transformer factory
- 4XSLT, part of 4Suite is an open source command-line processor for XSLT 1.0, used on Unix systems, see manpage
- xslt.js is an open source XSLT 1.0 wrapper for transformations in the browser
- Sarissa is a reliable open source XSLT 1.0 and XML wrapper for transformations in a browser
Tools and libraries
Various libraries and tools include:
- EXSLT, semi-standardized set of XSLT 1.0 extension functions and instructions
- FXSL, an XSLT 1.0 and XSLT 2.0 and 3.0 compatible library of a large set of functions
- xslt-sb, a large set of XSLT 2.0 functions, extensive documentation in German
- DocBook XSL a large set of XSLT stylesheets to render DocBook XML for PDF, HTML or e-Book
- FunctX is a large set of XQuery and XSLT 2.0 functions
- XSLT Standard Library provides a large set of commonly used XSLT 1.0 functionality
- XTC Unit testing in XSLT and XQuery
- Kernow is a free user interface to run multiple stylesheets and sources with Saxon 9.x
- IronXSLT for supporting XSLT intellisense in older Visual Studio versions (it newer versions, XSLT 1.0 intellisense is incorporated)
- Register fix for Visual Studio 2008 XSLT intellisense
- Calabash is an implementation of XProc, a standardizes XML pipeline language, used for multiple steps processing of XML
- EXPath is a collaborative effort to define XPath (and therefore XSLT) extensions including a ZIP Facility, handling binary data, HTTP module etc. It evolved from EXSLT 2.0.
- SOAP and HTTP extensions for Saxon
- [XmlSpectrum] 74 is a syntax-highlighter for XSLT/XPath 3.0 - coded in XSLT
- See further a list of tools using XPath or based on XSLT-related technologies
History
XSLT was proposed by the W3C and has three standards: 1.0 in 1999, 2.0 in 2007 and 3.0 which was published 2017.
Question Tags
Questions should use one of the xslt-1.0, xslt-2.0, or xslt-3.0 tags as appropriate to clarify what XSLT version the question requires or references. If you are unsure which version your processor supports, you can check it with XSLT using <xsl:value-of select="system-property('xsl:version')"/>
, for instance, by running the stylesheet (self-referencing XML and XSLT) https://martin-honnen.github.io/xslt/processorTest3.xml through your processor.
XSLT Editors
Offline editors
- oXygen XML Editor (oxygenxml), cross-platform XML editor with enhanced XSLT and XQuery support including a powerful debugger and performance profiler
- Stylus Studio is an XML, XQuery and XSD editor including XSLT support.
- Altova is a graphical user interface to design mappings between XML files to create XSLT by drag and drop.
- Liquid XML allows you to debug XSLT and design XSLT and XML graphically
- EditiX is an XML editor with support for XSD, XSLT 1.0, 2.0 and 3.0 and comes with a debugger and profiler
Online editors
- Xsltransform.net - Online IDE for XSLT 1.0, 2.0, allows you to save code snippets for public reference
- Online IDE for XSLT 1 and 2, copy of xsltransform.net
- .NET XSLT fiddle is an ASP.NET MVC 5 "clone" of the Java/play framework based xsltransform.net and allows testing and running XSLT 3 and 2 with Saxon 10.6 HE and XSLT 1 with XslCompiledTransform, MSXML 6 and the browser's XSLT processor
- Online XSLT 2.0 Service provided by W3C, can be used to test your XSLT stylesheets
- XSLT 3 fiddle running purely client-side in the browser based on Saxon-JS 2
Resources
- XML Transformation resources on the W3C
- XSLT on Wikipedia
- XML on Wikipedia
- Download of G. Ken Holman's book "Practical Transformation Using XSLT and XPath" covering XSLT and XPath 2.0 as well as 1.0
Online Training Courses
- Foundations of XSLT 2 and XSLT 1 -- A Pluralsight course by Dimitre Novatchev
- The Evolution of XPath: What’s New in XPath 3.0 -- A Pluralsight video-course (4.5h) by Dimitre Novatchev
- "What's New in XSLT 3.0: Part 1" -- A Pluralsight video-course (5.5h), by Dimitre Novatchev