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

Re: Finding the maximun number of nodes

Subject: Re: Finding the maximun number of nodes
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 5 Jan 2001 13:38:42 -0800 (PST)
maximun pics
Hi Jeni,

Two things:

1. You're not being picky at all and I do enjoy your messages.

2. Of course, I know about this solution being of O(NxN) complexity.
Nevertheless I like it for almost 100% and word y word following the
definition of "maximum". I was thinking of another optimisation, not
mentioned by you, that might be very benefitial in some cases (the
worst case will still be O(NxN)):

Imagine that you could "break out" of the for-each loop immediately
after finding the first row having maximum number of columns.

Certainly this cannot be done with the available XSLT instructions, but
can be simulated by replacing the for-each loop with calling a
recursive template. In case there's only one row with a maximum number
of columns, and this row is the last one (the worst case), this
template will call itself for every next row of the table. In any other
case it will return immediately when a row with a maximum number of
columns has been found.

So, in contrast with the current solution, only one number will be
output -- not a delimited sequence.

In case of "regular tables" (with all rows having the same number of
columns) this solution will be of O(1) complexity!

Cheers,
Dimitre.

--- Jeni Tennison <mail@xxxxxxxxxxxxxxxx> wrote:
> Hi Dimitre,
> 
....................... 
> <xsl:variable name="tableRows" select="//table[@ID='2']/tr" />
> <xsl:for-each select="$tableRows">
>   <xsl:variable name="rowColumns" select="count(td)" />
>   <xsl:if test="not($tableRows[count(td) > $rowColumns])">
>       <xsl:value-of select="count(td)"/>:
>    </xsl:if>
> </xsl:for-each>
> 
> Sorry if I'm being picky :)
> 
> Cheers,
> 
> Jeni
> 
> ---
> Jeni Tennison
> http://www.jenitennison.com/
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/

 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.