Subject: RE: What did "template match" match?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 5 Aug 2005 15:56:08 +0100
|
> > > 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/
|