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

Re: determining whether an XPATH points to an element

Subject: Re: determining whether an XPATH points to an element or attribute
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 23 Jan 2002 10:10:23 GMT
xpath tagname
> Sorry I was a bit unclear.

ah the second version was clearer but still...

 want to generate the following template match rule for an XPATH pointing to a element

<xsl:template match="//tagname">

Note that prefixing a match expression with // never does anything
except perhaps change the default priority. match="//tagname"
matches the same elements as match="tagname"
<xsl:template match="@attributename">
matches the same attributes as <xsl:template match="//@attributename">

Going back to your first message..

<xsl:template match="//tagname">
		<xsl:when test=" current() = some sort of test  "><!--
	if it points to element -->

in this case the template only matches elements.

If you really want a template that matches both elements and attributes
you need to do something like

<xsl:template match="tagname|@tagname">
Then you can tell if you have an element or an attribute by
<xsl:if test="self::*">which is true just on element nodes

but this is a rather strange thing to do as 999 times out of 1000 you
always know in a template what kind of node is being matched.


This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.