This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: determining whether an XPATH points to an element or attribute
- From: David Carlisle <davidc at nag dot co dot uk>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 23 Jan 2002 10:10:23 GMT
- Subject: Re: [xsl] determining whether an XPATH points to an element or attribute
- References: <95B3DC792A040C45807C9CFA11B7B1AF02DE45C2@OHISV4.nikonoa.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
> 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">
<TagOperation>
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"
and
<xsl:template match="@attributename">
matches the same attributes as <xsl:template match="//@attributename">
Going back to your first message..
<xsl:template match="//tagname">
<xsl:choose>
<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.
David
_____________________________________________________________________
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