xsl-list
[Top] [All Lists]

Re: Finding last node in recursive tree

2003-08-07 12:52:10
Not sure if I understand you correct but here is what
I think will work. 

you can use something like this


<xsl:if test="count(following-sibling::node())=0">

in the template which matches the <dataset> element.
If there are no more dataset elements following the
current dataset element with the same parent thus
meaning in the same nodeset then this will return a
value true else it will be false.
For example in the following context

    <stuff>
1    <dataset>
2      <dataset>
          <stuff/>
3          <dataset>
             <stuff/>
          </dataset>
4          <DATASET>
             <stuff/>
          </dataset>
          <stuff/>
      </dataset>
    </dataset>
   </stuff>

Thus this will return a value of TRUE for nodes named
1 2 and 4 while it will return FALSE for 3 since it is
not the last dataset element.
Hope this helps.

Good Luck !
Abhi

Abhijit Junnare


--- "Woosley, David" <David(_dot_)Woosley(_at_)imrm(_dot_)com> wrote:
Assume my XML document contains one or MORE
hierarchies of 'dataset' nodes,
like this:
                      
<report>
   <stuff/>
   <dataset>
      <dataset>
         <stuff/>
      </dataset>
      <dataset>
         <stuff/>
      </dataset>
   </dataset>
      <stuff/>
   <dataset>
      <dataset>
         <stuff/>
         <dataset>
            <stuff/>
         </dataset>
         <DATASET>
            <stuff/>
         </dataset>
         <stuff/>
      </dataset>
   </dataset>
      <stuff/>
</report>

The 'dataset' levels will vary in depth.  Other
elements will be sprinkled
among the 'dataset' nodes.  How can I determine when
I am at the beginning
of the very LAST 'dataset' node (the node in caps
above), regardless if its
depth?

Many thanks,

David Woosley



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



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



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