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

Re: Can I test the name of the current element?

Subject: Re: Can I test the name of the current element?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 30 Jan 2003 23:29:40 GMT
name of th
> My apologies if this is in a faq somewhere, I had no luck finding a
> solution there.

searching the faq or the Xpath spec would I'm sure have shown that the
name() function returns the name of the current node.


    <xsl:when test=".=Line"> <!-- something like this -->

that tests the string value of the current node (which is empty for
empty elements) against the string value of the Line child of the
current node (which is empty as these nodes have no children at all)

so you want
    <xsl:when test="name()='Line'"> <!-- something like this -->
which tests the name of the current node against the string 'Line'
but actually it's better to instead do
<xsl:when test="self::Line">
which is simpler and more robust should you ever use namespaces.

alternatively the natural implementation of
> However I need to process them a second time differently:
is to use a mode,
get rid of your xsl:choose and use
<xsl:apply-templates mode="abc"/>
then you just need
<xsl:template match="Line" mode="abc"> L </xsl:template>
<xsl:template match="Curve" mode="abc"> C </xsl:template>

David

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


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.