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:apply-templates/> </xsl:variable> <xsl:template match="*[$x]"> ... </xsl:template> To circumvent the restriction, you need to use an xsl:choose inside the template: <xsl:template match="*"> <xsl:choose> <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: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Are variables allowed in , David Carlisle | Thread | RE: [xsl] Are variables allowed in , Roger Glover |
Re: [xsl] Are variables allowed in , David Carlisle | Date | Re: [xsl] Problem reading root elem, David Carlisle |
Month |