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

Is this node, the document root... best test?

Subject: Is this node, the document root... best test?
From: Stephen Cunliffe <scunliffe@xxxxxxxxxxxxxxxxxx>
Date: Mon, 20 Oct 2003 10:58:58 -0400
root node name
Hello XSL group;

In a template, matching on "*", I need to test, if this node, is the document root node.

E.g.

<xsl:template match="*" mode="someTemplate">
 <xsl:choose>
   <!-- Method (1) -->
   <xsl:when test="not(parent::*)">
     This works, but is it safe/efficient?
   </xsl:when>
   <!-- Method (2) -->
   <xsl:when test="string(name(parent::*)) = ''">
     This works, but is it safe/efficient?
   </xsl:when>
   <xsl:otherwise>This node, is *NOT* the root node...</xsl:otherwise>
 </xsl:choose>
</xsl:template>

Question:
What is the best/simplest/recommended method (must be non-parser specific)?
In terms of processing speed?
In terms of just plain cool?
(e.g. I was hoping that "not(..)" would work ;-)


I'm open to any/all options, the 2 above are just one's I've had luck with.

PS I'm currently leaning towards Method 1, above.

PPS I want to be careful, that I don't try and match the
   node's "name" against the document root node's "name",
   as this may provide a false match.

Cheers,

Steve



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.