RE: [xsl] Are variables allowed in XPATHs?

Subject: RE: [xsl] Are variables allowed in XPATHs?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Mon, 3 Feb 2003 09:50:46 -0000
> I must say, I find this restriction somewhat 
> amazing.  I assume it's intended to reduce the 
> complexity of writing XSL processors?

Actually I stated the restriction wrongly. Some patterns in XSLT can
contain variable references, but the ones used in the match attribute of
xsl:template and xsl:key can't.

The restriction was a misguided attempt to eliminate the possibility of
circularities, in constructs like:

<xsl:variable name="x">

<xsl:template match="*[$x]">

To circumvent the restriction, you need to use an xsl:choose inside the

<xsl:template match="*">
   <xsl:when test="position()=$x">

The restriction has been lifted in XSLT 2.0.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

 XSL-List info and archive:

Current Thread