RE: Scripting on XSL elements in ie5 after page is loaded

Subject: RE: Scripting on XSL elements in ie5 after page is loaded
From: Mark Birbeck <Mark.Birbeck@xxxxxxxxxxxxx>
Date: Mon, 22 Feb 1999 22:35:28 -0000
Dana Fillhart wrote:
> I'm trying to allow somebody to sort a table of data based 
> upon a column
> they choose.
[snip of lots of books!]
> Now, the trick is, when the user clicks on one of the buttons 
> at the bottom,
> I want to, *without reloading the page*, reapply the 
> for-each, and arrange
> the table columns based upon the one they chose.  Or if they 
> click one of
> the ascending/descending buttons, the table data will be reordered
> accordingly (again without having the page reload).  I've 
> tried <xsl:script>
> blocks, but ie5's parser complains that "<xsl:script> keyword 
> cannot be used
> here" (or something to that effect).  I can do normal 
> <script>, but I don't
> know how to programmatically access the xsl elements or methods.
> 
> Any ideas on how to do what I want to do?  I do NOT want to 
> create separate
> stylesheets for each possible permutation the user may 
> select, then reload
> the page; that's rediculous, especially if something changes, 
> like a new
> child element is later introduced in the data and must be sorted upon.

Three methods I can think of:

1. Instantiate two DOM objects, one with the XML in, and one with the
XSL, then apply the latter to the former to get your page. Then, when
the user presses something, change the correct node in the XSL DOM to
the new rule you want and then reapply to the XML DOM. Then redisplay
the result. You could get clever, and after displaying the full page
from the first stylesheet, create *another* DOM and in it put just the
small bit of XSL you need. Then you could apply that to the XML object,
and then use DHTML to replace the correct segment in the page (put a DIV
around the rows in the *first* stylesheet).

2. If you have server-side scripting then another method would be to
generate the XSL dynamically - the browser won't know any different.

3. Write a JavaScript function for the browser that sorts rows in a
table using DHTML. The function could easily be generalised to sort any
rows appearing within a DIV, by any of the columns, and so included in
all your files.

Although I am a big fan of XSL I prefer approach number 3, (although we
do use method 2 when we want data from a database in the stylesheet, but
we don't want to put it into the XML side). My reasoning is that it is a
lot easier to maintain a large site when all you ever do is
XML+XSL=HTML. This may be done on the server for some browsers, and on
the browser itself for IE5 and others, but regardless of where it is
done, it has the merit of remaining a simple equation. It could even be
performed as a batch process every 24 hours.

If, however, some pages start to have their own control over their
nodes, then things become more difficult to maintain. Having said that,
if you're not dealing with hundreds of pages - perhaps writing a
web-based application of some sort - then it may not make any difference
anyway, and you will learn a lot from trying to implement method 1.

Regards,

Mark

Mark Birbeck
Managing Director
Intra Extra Digital Ltd.
39 Whitfield Street
London
W1P 5RE
w: http://www.iedigital.net/
t: 0171 681 4135
e: Mark.Birbeck@xxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread