Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: How to compute a node's depth in XSLT? -- Solved

From: "datamodel" <datamodel@-----.--->
To: 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() &lt; 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.



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent