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
5
votes
1 answer

PostgreSQL 8.4 XML, XSLT and XPath possibilities / documentation

The available PostgreSQL material on XML, XSLT and XPath is limited. There are the official docs from the PostgreSQL team, however these cover only a few pages of content and I've never been convinced that their docs are as comprehensive as they…
CitrusTree
  • 184
  • 2
  • 10
5
votes
1 answer

The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table)

The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) I am getting above warning in console . I am trying to do export to doc. With same XML and XSLT my export to PDF is working but export to doc gives blank…
5
votes
1 answer

Applying templates to elements in a variable/sequence

When I use "apply-templates" and select a variable sequence, does the template act upon the context of the element in the sequence, or does it act upon the context of the element in the document? In the below example, it seems to do either, or none,…
5
votes
1 answer

XslLoadException: Resolving of external URIs was prohibited

I have xslt sheet the have include tags for another xslt files, the all files compiled right and error free but when run the following code i got exception var myXslTrans = new XslCompiledTransform(); XsltSettings sets = new…
mbugr
  • 322
  • 1
  • 4
  • 23
5
votes
3 answers

node-gyp rebuild fails while installing node modules

I am trying to install node_xslt module in node 0.12 but it is failing. I have python version 2.7 and node-gyp version 2.0.2. Here is the error stack- > node_xslt@0.1.9 preinstall /home/ritesh/Ritesh/projects/applane1/node_modules/node_xslt >…
Ritesh Bansal
  • 3,108
  • 2
  • 16
  • 23
5
votes
1 answer

xsl:character-map to replace special characters

Given an element with a value of: Distrib = SU & Prem &lt;&gt; 0 I need to turn &lt; or &gt; into < or > because a downstream app requires it in this format throughout the entire XML document. …
johkar
  • 435
  • 3
  • 8
  • 12
5
votes
2 answers

Strip leading spaces only

Given element: comments go here How can I strip what may be multiple leading space characters. I cannot use normalize space because I need to retain newlines and such. XSLT 2.0 ok.
johkar
  • 435
  • 3
  • 8
  • 12
5
votes
4 answers

Transforming XML into HTML (as opposed to xhtml)

i want to transform some xml into HTML that has the following format: col1 col2 col3 Note: The output is HTML, complete with optional closing tags omitted. This is the problem, and the reason the question exists. A snippet…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
5
votes
3 answers

XSLT transformation on Large XML files with C#

I have some very large XML files (800 MB to 1.5 GB). I need to apply XSLT on that. I am able to read it XMLTextReader. When i applied XSLT transformation, get SystemOutOfMemory Exception. My code looks like; static void Main(string[] args) { …
jvm
  • 1,662
  • 8
  • 27
  • 46
5
votes
1 answer

XSLT 2.0 regular expression replace

I have the following XML: a_35345_0_234_345_666_888 I would like to replace the first occurrence of number after "_" with a fixed number 234. So the result should look like: a_234_0_234_345_666_888 I have tried using the following…
M Tracker
  • 75
  • 1
  • 1
  • 5
5
votes
3 answers

Is there a way to XSLT to echo out the XML powering it?

I am using XSLT to transform XML. Is there a way for the XSLT to spit out the XML that is feeding it? Something like:
Andrew G. Johnson
  • 26,603
  • 30
  • 91
  • 135
5
votes
1 answer

XPath explicit index filter performance

I am creating a xsl stylehseet and came up with this (in my opinion illogical behavior): This XPath: /root/element[1][@attr1 != '1' or @attr2 != 'test'] is WAY slower than this XPath: /root/element[count(preceding-sibling::element) + 1 = 1) and…
AlteGurke
  • 585
  • 6
  • 20
5
votes
1 answer

Xml to html using xslt of inspect code of VS Projects

I have a an InspectionResults.xml which gets generated when I run inspectcode.exe from JetbrainsCommandLine Tool Analysis. Is there any xslt file provided by the Jetbrains to convert this xml to html. I was able to convert DuplicateReport.xml to…
user4373126
5
votes
2 answers

Lowercase conversion in XSL

I have an XML like Jack Dawson Jack Thompson I am developing a web application which searches this xml based on the first name…
Bala
  • 51
  • 1
  • 1
  • 2
5
votes
2 answers

Error message in XSLT with C# extension function

I am received the following error while trying to implement a C# extension function in XSLT. Extension function parameters or return values which have CLR type 'Char[]' are not supported.** code:
developer
  • 7,252
  • 14
  • 49
  • 57
1 2 3
99
100