XSLT

XSLT stands for Extensible Stylesheet Language Transformations and is a functional programming language that is primarily used to transform XML documents into other XML documents or data formats such as HTML, CSV or JSON. XSLT is superior to many other programming languages when it comes to processing XML. This is not least due to the fact that XSLT supports the XPath query language, which can be used to navigate from one location in the XML document to any other location.

XSLT was adopted as a standard (W3C Recommendation) by the World Wide Web Consortium (W3C) in 1998. However, the functionality of the first version was quite limited, which made demanding tasks unnecessarily complicated. Versions 2.0 and 3.0, released in 2001 and 2017, added various useful functions and programming concepts, so that today programming with XSLT is considered efficient and convenient.

The XSLT processor reads the XML document, applies the XSLT stylesheet to it and creates the output document.

An XSLT stylesheet is essentially based on templates that can select and edit various locations in the XML document using XPath. The result of the template is then written into the same location in the output XML document. Here is a small XSLT example with two templates. The first template creates the typical HTML basic structure at the start of the DocBook document. The second template picks out the DocBook chapter title and creates an HTML heading from it.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/1999/xhtml" 
    xpath-default-namespace="http://docbook.org/ns/docbook"
    version="3.0">
  
  <xsl:template match="/">
    <html>
      <head>
        <title>My fresh HTML document</title>
      </head>
      <body>
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="chapter/title">
    <h1>
      <xsl:apply-templates/>
    </h1>
  </xsl:template>
  
</xsl:stylesheet>

XSLT is also available as a tool in many other programming languages. For example, XSLT stylesheets can be executed in Java, .NET, C/C++, Python, PHP and NodeJS. XSLT can also be used in web browsers: Although all modern browsers today only support the outdated XSLT 1.0 natively, XSLT 3.0 can also be used with external JavaScript libraries.

Because of its unequivocal focus on XML processing, XSLT is certainly not one of the most popular programming languages today. But in this respect, there is no other programming language that can hold a candle to XSLT.