Translate

Archives

XSLT 1.0 Multiple Namespace Issues

This post discusses namespaces in XML documents and XSLT 1.0 stylesheets. In particular, it demonstrates a number of techniques to control namespace prefixes and declarations in outputted documents.

XSLT Variable Arrays

I recently answered a question on a popular programmers forum about how to store and access an array of user-defined variables in a stylesheet and then loop though those variables.  I realized that many developers are not familar with the available techniques for doing this and decided to add an entry in my blog about this topic. User-defined variable arrays within stylesheets are not part of the XSLT specification.  The usual way to handle this problem in XSLT 1.0 stylesheets is to define a user-defined top-level element which belongs to a non-null namespace which is different from the XSLT namspace.  These user-defined

XSLT Copy with Exception

A recent problem that was posed to me concerned how to copy the entire contents of an XML document with certain exceptions.  Turns out that the simplest way to handle this requirement in XSLT1.0 was to include the standard XSL identity template in my stylesheet and add another template to handle the exception. A simple example will make things clearer.  Suppose we have the following XML document (which I shamelessly copied from W3Schools.com and modified to simplify) and we want to copy this document in its entirety except for details of CDs by a specific artist. <?xml version="1.0"?> <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE>

XSLT Dynamic Path Evaluation

This post discusses the problem of dynamic XPath expression evaluation in XSLT 1.0 and XSLT 2.0 and how to handle it using an EXSLT extension function.

XSLT DateTime Formatting

Support for date and time formating in the XSLT 1.0 specification is non-existent. This did not mean that a person cannot format date and time strings using XSLT 1.0; it just makes it much harder to do so and adds many extra lines of code to stylesheets. However it is something that everybody who develops stylesheets ends up having to do. In this post I show you several ways to format dates in XSLT 1.0 and discuss some of the new dateTime formating and manipulation functions in XSLT 2.0 and XPath 2.0.