xsl-list
[Top] [All Lists]

RE: xsl:apply-templates with variable

2004-09-21 13:35:40
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(_at_)onebox(_dot_)com - email