RE: [xsl] xsl:apply-templates with variable

Subject: RE: [xsl] xsl:apply-templates with variable
From: cknell@xxxxxxxxxx
Date: Tue, 21 Sep 2004 16:35:40 -0400
The last exception points you in the right direction.

"javax.xml.transform.TransformerException: A node test that matches
either NCName:* or QName was expected."

The spec specifically prohibits the kind of dynamic evaluation in template matching and in XPath expressions. Michael Kay has answered this kind of question many times on this list.

You might try a construct like this:

<xsl:choose>
  <xsl:when test="$ROOT='CUSTOMER'">
    <xsl:apply-templates select="CUSTOMER"/>
  </xsl:when>
  <xsl:when test="$ROOT='DEPARTMENT'">
    <xsl:apply-templates select="DEPARTMENT"/>
  </xsl:when>
  <xsl:otherwise>
<!-- Default template match goes here -->
  </xsl:otherwise>
</xsl:choose>
-- 
Charles Knell
cknell@xxxxxxxxxx - email

Current Thread