Subject: select="preceding-sibling::ROW[entered_formatted_day=$currentFruit]" is too slow From: Thorbjoern Ravn Andersen <ravn@xxxxxxxxxx> Date: Sun, 2 Apr 2000 15:24:03 +0200 (MET DST) |
I am currently writing a small application using the Apache Cocoon technology (Cocoon 1.7, Xalan 1.0) , and I am using XSLT to massage the output from an SQL-request into a list. My structure looks like this <list-by-date-query> <ROW> <entered_formatted_data>2000-04-02</entered_formatted_data> ....A... </ROW> <ROW> <entered_formatted_data>2000-04-02</entered_formatted_data> ....B... </ROW> <ROW> <entered_formatted_data>2000-04-01</entered_formatted_data> ....C... </ROW> </list-by-date-query> Which I would like rendered as <h2>2000-04-02</h2> A stuff B stuff <h2>2000-04-01</h2> C stuff In e.g. perl I would have had a variable which held the previous value, so I could output the entered_formatted_data when the value changed. Apparently this isn't easy to do in XSLT. Browsing the list archives, I ended up with this code: <xsl:template match="list-by-date-query/ROW"> <xsl:variable name="currentFruit"><xsl:value-of select="entered_formatted_day"/></xsl:variable> <xsl:variable name="others" select="preceding-sibling::ROW[entered_formatted_day=$currentFruit]"/> <xsl:if test="count($others) = 0"> <h2><xsl:value-of select="entered_formatted_day"/></h2> </xsl:if> which works but has the following problems: 1) It is too slow. With 100 elements in the table it responds in about 5 seconds, with 300 elements the web browser times out. 2) I do not understand it fully. After spending quite some time trying just to get to the entered_formatted_day field in the preceding-sibling (Xalan is not very helpful in its error messages) the above worked. I am suspecting that the matching code looks over the whole table instead of just the previous element, which might be causing my problems. I am not running out of memory as such - java takes about 20 Mb - but it runs at full speed for at least 8 minutes (long after the browser timed out). I would appreciate a hint to how I can speed up the "is this value different from the value of the same tag in the previous tag". Apparently this list has the expertise :-) Thanks in advance, -- Thorbjørn Ravn Andersen "...plus...Tubular Bells!" http://www.mip.sdu.dk/~ravn XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: string-length, Steve Tinney | Thread | RE: select="preceding-sibling::ROW[, Didier PH Martin |
RE: string-length, Ben Sorek | Date | RE: select="preceding-sibling::ROW[, Didier PH Martin |
Month |