[Home] [By Thread] [By Date] [Recent Entries]
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
|

Cart



