Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - How to compute a node's depth in XSLT? >Thread Next - Re: How to compute a node's depth in XSLT? -- Solved Re: How to compute a node's depth in XSLT? -- SolvedTo: NULL Date: 12/2/2006 6:22:00 PM This solution is in XSLT 1.0 not very elegant to the time complexity - I used the function : count(ancestor::NODES) to determine a value for the depth of a given <NODE> node. datamodel wrote: > Hello I have an XML tree of which you can see a mini-version here: > > http://paste.uni.cc/11838 > > (the tree is actually over 30,000 levels deep) > > How do I count the depth of a given <NODES><NODE> ????? > > The problem is I would like to "color" nodes based on their depth in > the tree - ie, use alternating colors. > > A depth, or actually "level" in the logical tree actually comprises two > levels in the XML tree - ie > <NODES><NODE> > > There is no depth attribute in the XML tags, > and the position() function applies only to the currently processed > node, > > Ideally I want to construct a test like > > <xsl:if test="[parent::position() < 3]"> > > of course this is wrong syntax. > > and position() doesn't help , since it really computes the position in > the siblings at a given level, > not the level of depth in the tree. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
