Subject: Re: [xsl] Finding the maximun number of nodes From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Fri, 5 Jan 2001 13:38:42 -0800 (PST) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Finding the maximun numbe, Clapham, Paul | Thread | Re: [xsl] Finding the maximun numbe, Jeni Tennison |
[xsl] xsl:key and document(), Robert Goheen | Date | [xsl] xsl:when - comparing paramete, RUSSO, EDITH |
Month |