|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Scripting on XSL elements in ie5 after page is loaded
I'm trying to allow somebody to sort a table of data based upon a column
they choose.
Let's use the books example on Microsoft's site:
<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="bookstyle.xsl"?>
<books>
<book>
<title>Pierre: The Ambiguities</title>
<author>Herman Melville</author>
<price>9.99</price>
</book>
<book>
<title>Heart of Darkness</title>
<author>Joseph Conrad</author>
<price>12.99</price>
</book>
<book>
<title>Arrowsmith</title>
<author>Sinclair Lewis</author>
<price>8.99</price>
</book>
<book>
<title>Oedipus Rex</title>
<author>Sophocles</author>
<price>8.99</price>
</book>
<book>
<title>The Secret Sharer and Other Stories</title>
<author>Joseph Conrad</author>
<price>13.99</price>
</book>
<book>
<title>The Republic</title>
<author>Plato</author>
<price>12.99</price>
</book>
<book>
<title>The Republic</title>
<author>Plato</author>
<price>15.99</price>
</book>
<book>
<title>Pragmatism</title>
<author>William James</author>
<price>15.99</price>
</book>
</books>
The bookstyle.xsl stylesheet lays out the table like this:
<?xml version="1.0"?>
<root xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<head>
<title>Book table example</title>
</head>
<html>
<body>
<DIV>
<input id="btnAscending" type="button" value="Sort Ascending"/>
<input id="btnDescending" type="button" value="Sort
Descending"/><br/>
<TABLE style="table-layout:fixed" BORDER="2" CELLSPACING="2">
<col width="200"/>
<col width="200"/>
<col width="200"/>
<THEAD>
<TH id="thAuthor">AUTHOR</TH>
<TH id="thTitle">TITLE</TH>
<TH id="thPrice">PRICE</TH>
</THEAD>
<xsl:for-each select="books/book" order-by="+author">
<TR>
<TD>
<i>
<SPAN id="spnAuthor" style="font-weight: bold;">
<xsl:value-of select="author"/>
</SPAN>
</i>
</TD>
<TD>
<SPAN id="spnTitle">
<xsl:value-of select="title"/>
</SPAN>
</TD>
<TD>
<SPAN id="spnPrice">
<xsl:value-of select="price"/>
</SPAN>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</DIV>
<input id="btnAuthor" type="button" value="Author"/>
<input id="btnTitle" type="button" value="Title"/>
<input id="btnPrice" type="button" value="Price"/><br/>
</body>
</html>
</root>
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.
Thanks!
--
Dana Fillhart
Software Engineer
Proxicom, Inc.
www.proxicom.com
(212) 363-6580 ext. 3047
(212) 363-6522 (fax)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








