Category Archives: xslt

>XSLT 2.0: select attribute within xsl:choose

XSLT 2.0 (which includes XPath 2.0) is enhances XSLT 1.0 in many ways. Among other improvements, it supports regular expressions, multiple output documents, plain text parsing, etc.

However, of course there’s always more on one’s wishlist; or at least on mine. I’d like to see support for the select attribute on xsl:when and xsl:otherwise attributes. Currently, with XSLT 2.0, the following is a typical construct:

<xsl:when test="@lang">
<xsl:value-of select="@lang">
<xsl:value-of select="$defaultLang" />

With my proposed change this can be reduced to:

<xsl:when test="@lang" select="@lang" />
<xsl:otherwise select="$defaultLang" />

It’s shorter, easier to read and probably quite straight-forward to implement in parsers. And IMHO it is even consistent with the rest of the language, because since XSLT 2.0 even the <xsl:with-param> element supports the select attribute…

Leave a comment

Posted by on 15 November 2007 in xslt