[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: counting leaf nodes

Subject: RE: counting leaf nodes
From: "Mike Ball" <mike.ball@xxxxxxxxxxxxxxxx>
Date: Wed, 30 Aug 2000 17:00:29 +0100
leaf nodes
Hi Perry

<xsl:value-of select="count(descendant::*[not(child::*)])"/>

gives the count of leaf elements below the current element. Or

<xsl:value-of select="count(descendant::su[not(child::*)])"/>

if you only want ot count "su"s.

There may however be more efficient/elegant ways, I'm no guru.

Hope that helps

Mike Ball

 
Application Services Consultant
Software AG UK


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Perry Roland
> Sent: 30 August 2000 16:03
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: counting leaf nodes
> 
> 
> 
> Hi,
> 
> I need some help with an expression that will count the leaf
> nodes on a given branch.  Let's say I have XML like
> 
> <su><!-- top level -->
>         <su><!-- 2nd level -->
> 		<su><!-- 3rd level -->
> 			<su><!-- 4th level --></su>
> 			<su><!-- 4th level --></su>
> 			<su><!-- 4th level --></su>
> 		</su>
> 	</su>
>         <su><!-- 2nd level -->
> 		<su><!-- 3rd level --></su>
> 		<su><!-- 3rd level --></su>
> 		<su><!-- 3rd level --></su>
> 	</su>
> </su>
> 
> My goal is to be able to output this as an HTML table like
> 
> <TABLE BORDER=1>
> <TR><TD COLSPAN=6>*</TD></TR> <!-- top level -->
> <TR><TD COLSPAN=3>*</TD><TD COLSPAN=3>*</TR> <!-- 2nd level -->
> <TR><TD COLSPAN=3>*</TD><TD>*</TD><TD>*</TD><TD>*</TD></TR> <!-- 
> 3rd level -->
> <TR><TD>*</TD><TD>*</TD><TD>*</TD></TR> <!-- 4th level -->
> </TABLE>
> 
> As I process each su element, in order to calculate the COLSPAN
> attribute, I need to know how many su elements there are below the
> current one that don't have su children themselves.
> 
> Any help is appreciated.
> 
> --
> perry
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.