Subject: Re: [xsl] Maximum number of cells From: Goetz Bock <bock@xxxxxxxxxxx> Date: Wed, 20 Dec 2000 23:13:50 +0100 |
Hi Mark, > I need to compare the number of cells in each row element and get the count > of cell elements in the row that has the most (3 in this case). Does anyone > have any ideas? Any help would be greatly appreciated. I don't have the time th check this, but the sollution should be somewhat along the line of: <template match="table"> <variable name="max_cols"> <call-template name="count_cols_per_row"> <with-param name="row"> <value-of select="count(row)"/> </with-param> </call-template> </variable> <!-- do your processing here --> </template> <tempalte name="count_cols_per_row"> <param name="row">0</param> <param name="max_cols">0</param> <choose> <when test="row > 0"> <variable name="cols"> <value-of select="count(row[$row]/col)"/> </variable> <variable name="max"> <choose> <when test="$max_cols %lt; $cols"> <value-of select="$cols"/> </when> <otherwise> <value-of select="$max_cols"/> </otherwise> </choose> </variabe> <call-template name="count_cols_per_row"> <with-param name="row"> <value-of select="$row - 1"/> </with-param> <with param name="max_cols"> <value-of select="$max"/> </with-param> </call-template> </when> <otherwise> <value-of select="$max_cols"/> </otherwise> </choose> </template> This should to the trick, it can for sure be optimized and now has about O(rows) runtime. Cu, Goetz.
Attachment:
pgp00002.pgp
Description: PGP signature
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Maximum number of cells, Dudley, Mark | Thread | Re: [xsl] Maximum number of cells, Miloslav Nic |
[xsl] Printed Output, Josiah Gordon | Date | [xsl] parent node/ child node, James Piva |
Month |