XSLT

2011

Disable-output-escaping and xsl:character-map

"DOE is short for "disable-output-escaping". DOE is the name of an attribute we can use in xsl:value-of and in xsl:text. XSLT processors are not required to support it, and in XSLT 2.0 DOE is deprecated. We should use xsl:character-map instead. "Character-map" is a general method for replacing a character with a string when output is serialized."

2010

Transform XML to CSV with XSLT pipeline

This tutorial is a showcase for the templating power of XSLT. The XML to CSV solution is a pipeline of 7 xslt stylesheets providing user-defined pre-processing and automatic flattening and equalizing. Comma, quote, linebreak, leading and trailing whitespace are supported in data.

2009

xsl:namespace in XSLT 2.0

The xsl:namespace element is most often useful if namespaces are created dynamically or if they are part of content of elements and attributes as QNames, or if we for cosmetic reasons want to transfer namespace declarations from inner elements to outer element in output.

2008

Elements and functions available in XSLT processors

In XSLT we can use the functions element-available() and function-available() to see what instruction elements and functions are available including extensions. I have made an XSLT stylesheet testing the availability of all XSLT instruction elements, XSLT and XPath functions and Saxon and EXSLT extensions.

XSLT 2.0 Saxon in ASP.NET

XSLT 2.0 became standard in 2007 and we want to use it in ASP.NET. Microsoft has not made an XSLT 2.0 processor yet, but who really cares. It is easy to use the .net version of the Saxon XSLT 2.0 processor instead. This is a tutorial to get you started.

Identity transformation for XSLT 2.0

The traditional identity template has several shortcomings. The most important are that XML declaration and DTD are not recreated and that default attributes found in DTD are copied to the output. In XSLT 2.0, using saxon-parse() and saxon-serialize(), it is possible to supplement the identity template with extra templates and instructions overcoming all limits and inconveniences.

2007

User-defined function for line-number in XSLT

In XSLT 2.0 we have 130 functions but we don't have a function to return the line-number of an element node. It is a challenging exercise to make a user-defined function for line-number. We need to get a lot of the new stuff in XSLT 2.0 working, like sequences, unparsed text and Regular Expressions.

Collection() with REGEX in XSLT

Collection() is a non-standardized standard function. It can be used as a better version of document() and doc() with wild cards and Regular Expressions to load a collection of XML documents. Or it can use a catalog file.

2006

Tricky whitespace handling in XSLT

The xsl:strip-space and xsl:preserve-space elements are only relevant for whitespace-only text nodes. Some XSLT processors have not even implemented these elements but strip such nodes themselves.

XSLT 1.0 Element Syntax Summary (group)

This element syntax summary is an enhanced and a more user-friendly version of the syntax summary in the XSLT 1.0 Recommendation. The headings link to the spec for additionel information.

XSLT 1.0 Element Syntax Summary (a-z)

This element syntax summary is an enhanced and a more user-friendly version of the syntax summary in the XSLT 1.0 Recommendation. The headings link to the spec for additionel information.

Using unparsed-text() in XSLT 2.0 to test prolog

In XSLT 2.0 we can use the unparsed-text() function to test the XML declaration and the DOCTYPE declaration. We can read the pseudo-attributes of the XML declaration and the values of PUBLIC or SYSTEM in the DTD in order to recreate or modify them as we please.

2005

Identity Template: xsl:copy with recursion

The so-called identity template that copies everything from input.xml to output.xml, element for element, attribute for attribute, is the most important of all templates in combination with templates of exceptions.

Updated: 2010-09-17