This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XPATH : How to get the level of a node (depth) ?
- To: "xsl-list at mulberrytech dot com" <xsl-list at mulberrytech dot com>
- Subject: Re: XPATH : How to get the level of a node (depth) ?
- From: "Juergen Hermann" <jhe at webde-ag dot de>
- Date: Mon, 14 Feb 2000 13:39:51
- Reply-To: xsl-list at mulberrytech dot com
On Mon, 14 Feb 2000 12:10:04 +0100, Eric RUBINAT wrote:
> How can i get the depth of a node...?
Using Xalan, you'll get this
DOCUMENT: 0
HEADER: 1
LINE: 2 toto
LINE: 2 titi
BODY: 1
LINE: 2 the body text here
from this stylesheet
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()">
<xsl:value-of select="name(.)"/>: <xsl:value-of select="count(ancestor::*)"/>
<xsl:apply-templates select="node()"/>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list