[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Maximum number of cells
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|