xsl-list
[Top] [All Lists]

RE: What did "template match" match?

2005-08-05 07:56:08
When my template matches a number of possible patterns:

    <xsl:template match=3D'X|Y'> ... </xsl:template>

Is there a way of determining the value of what was actually
matched? 

No.

If you want different behavior for the two cases, split it up 
into two templates.

No! As Benjamin Boksa said, "name()" can do it:

<xsl:template match="todo|author|changes">
      <xsl:value-of select='name()'/>
      <xsl:element name='{name()}'>
              <xsl:apply-templates/>
      </xsl:element>
</xsl:template>


That's assuming the different patterns match different names. Doesn't work
for, say

match="chapter/title | section/title"

Michael Kay
http://www.saxonica.com/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>