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

select="preceding-sibling::ROW[entered_formatted_day=$curren

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)
preceding sibling row
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

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.