This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: XPATH : How to get the level of a node (depth) ?


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]