RSS

>XSLT 2.0: select attribute within xsl:choose

15 Nov

>
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:choose>
<xsl:when test="@lang">
<xsl:value-of select="@lang">
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$defaultLang" />
</xsl:otherwise>
</xsl:choose>

With my proposed change this can be reduced to:

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

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…

Advertisements
 
Leave a comment

Posted by on 15 November 2007 in xslt

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: