Re: [xsl] Determining the level of the XML node?

Subject: Re: [xsl] Determining the level of the XML node?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Jan 2001 17:28:17 -0500
At 01/01/16 14:00 -0800, David M. Goudreau wrote:
Does anyone know how to determine what "level" the current node is at in the
XML using XSL?

If I've understood your use of the word "level", the expression count(ancestors::node()) will give you "1" for the document element, "2" for children of the document element, etc. It also considers an element's attribute as one deeper than the element itself.


Use count(ancestors::*) for a zero-origin count.

I hope this helps.

................. Ken


-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/m/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Web site: XSL/XML/DSSSL/SGML/OmniMark services, training, products. Book: Practical Transformation Using XSLT and XPath ISBN1-894049-05-5 Article: What is XSLT? http://www.xml.com/pub/2000/08/holman/index.html Next public instructor-led training: 2001-01-27,2001-02-21, - 2001-02-27/03-01,2001-03-05/07,2001-03-21, - 2001-04-06/07,2001-05-01,2001-09-19


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread