Questions tagged [xslt]

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:

  1. A stylesheet is created (typically a .xsl file).
  2. An XML data source is created (such as a .xml file).
  3. The XSLT processor is loaded with both the XSL and XML content.
  4. The XML document is parsed into an XPath Data Model (XDM) tree (XDM is similar to DOM).
  5. 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

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 , , or 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 (), 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

Resources

Online Training Courses

  1. Foundations of XSLT 2 and XSLT 1 -- A Pluralsight course by Dimitre Novatchev
  2. The Evolution of XPath: What’s New in XPath 3.0 -- A Pluralsight video-course (4.5h) by Dimitre Novatchev
  3. "What's New in XSLT 3.0: Part 1" -- A Pluralsight video-course (5.5h), by Dimitre Novatchev
38236 questions
133
votes
4 answers

What are the differences between 'call-template' and 'apply-templates' in XSL?

I am new in XSLT so I'm little bit confused about the two tags, and So can you list out the difference between them?
Venkat
  • 20,802
  • 26
  • 75
  • 84
132
votes
4 answers

Can you put two conditions in an xslt test attribute?

Is this right for When 4 < 5 and 1 < 2 ?
joe
  • 16,988
  • 36
  • 94
  • 131
131
votes
6 answers

How can I convert a string to upper- or lower-case with XSLT?

How do you do case conversion in XSL? UPPER CASE
mjs
  • 63,493
  • 27
  • 91
  • 122
131
votes
2 answers

Why do indexes in XPath start with 1 and not 0?

Some colleagues and I were comparing past languages we had programmed in and were talking about our experience with VBScript with its odd features such as 1-based index instead of 0-based indexes like almost every other language has, the reasoning…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
122
votes
6 answers

Case insensitive XPath contains() possible?

I'm running over all textnodes of my DOM and check if the nodeValue contains a certain string. /html/body//text()[contains(.,'test')] This is case sensitive. However, I also want to catch Test, TEST or TesT. Is that possible with XPath (in…
Aron Woost
  • 19,268
  • 13
  • 43
  • 51
116
votes
41 answers

Is XSLT worth it?

A while ago, I started on a project where I designed a html-esque XML schema so that authors could write their content (educational course material) in a simplified format which would then be transformed into HTML via XSLT. I played around…
nickf
  • 537,072
  • 198
  • 649
  • 721
112
votes
6 answers

Is there an XSLT name-of element?

In XSLT there is the to get the value of an element, but is there something to select the tag-name of the element? In a situation like this: Robert