[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: What did "template match" match?

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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.