|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Is this node, the document root... best test?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








