Re: [xslt] Using xpath expressions for mode attribute

On Thu, 9 Aug 2001, Vakoc, Mark wrote:

> Hi all,
> Could the mode of <apply-templates> be an xpath expression?
> Essentially, I have a stylesheet that looks like:
> <xsl:sylesheet>
> <xsl:param name="mode" select="'normal'"/>
> <xsl:template match="/">
> <xsl:choose>
> <xsl:when select="$mode = 'normal'"><xsl:apply-templates select="."
> mode="normal"/></xsl:when>
> <xsl:when select="$mode = 'simple'"><xsl:apply-templates select="."
> mode="simple"/></xsl:when>
> </xsl:choose>
> </xsl:template>
> <xsl:template match="/" mode="normal">normal</xsl:template>
> <xsl:template match="/" mode="simple">simple</xsl:template>
> </xsl:stylesheet>
> ----  I would like to do
> <xsl:template match="/"><xsl:apply-templates  select="."
> mode="{$mode}"/></xsl:template>
> To do this xsltApplyTemplatesComp would have to evaluate the expression, but
> I fairly sure this would violate spec.  Can anyone confirm/deny if this
> violates the spec?
> Thanks

The spec can be found at

According to section 7.6.2, "Curly braces are not recognized in an attribute
value in an XSLT stylesheet unless the attribute is specifically stated to be
one that is interpreted as an attribute value template; in an element syntax
summary, the value of such attributes is surrounded by curly braces."

In section 5.4, the element syntax summary of xsl:apply-templates is given as

  select = node-set-expression
  mode = qname>

No curly braces around qname after mode, so no, you can't do that.

Ignacio Vazquez-Abrams  <>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]