xsl-list
[Top] [All Lists]

RE: How to find out the level of an element

2005-12-08 02:57:16

Please ignore the syntex of for-each.
it should be "select" instead of "test".

Type error.

Best Regards.

Arun



From: "Arun Sinha" <arunsinha666(_at_)hotmail(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] How to find out the level of an element
Date: Thu, 08 Dec 2005 09:54:55 +0000

Hi,

Is it possible to find out fat what level a particular element is appearing from the root level?

For example:-

<a>
   <b>
      <c>
      </c>
   </b>
</a>

<a>
   <b>
      <c>
      </c>
   </b>
</a>

I tried the following code but it isn't working.

<xsl:variable name="LastLevel">
   <xsl:for-each test="//c[1]">
         <xsl:value-of select="count(ancestor::a | ancestor::b)" />
   </xsl:for-each>
</xsl:variable>

I need to find out the level of element <c>. In the above example it should be 2.

Thanks in advance.

Arun



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>