dynamic sorting

A

Alan Searle

I find that I can display structured data very nicely using XML with an
XSL template. As an extra 'goodie', I would like to give users the
ability to sort that data (for example with a button above a particular
column). What I need to know now is whether this is possible with
XML/XSL? Or do I need to resort to a programming language (maybe JScript?).

So far I have worked with the XML and XSL split into separate documents.
However, I would like to bundle everything into one file (so that it
can easily be moved or e-mailed) and was hoping that someone can tell me
if/how this can be done.

Any tips or pointers to HOWTOs or tutorials would be greatly appreciated.

Many thanks,
Alan Searle.

(PS: remove xxx if you want to e-mail me)
 
M

Martin Honnen

Alan said:
I find that I can display structured data very nicely using XML with an
XSL template.

It is likely a browser that displays the HTML document your XSLT
stylesheet creates as the result of a transformation. XSLT does not do
any "displaying".
As an extra 'goodie', I would like to give users the
ability to sort that data (for example with a button above a particular
column). What I need to know now is whether this is possible with
XML/XSL? Or do I need to resort to a programming language (maybe
JScript?).

XSLT 1.0 has the xsl:sort element you can use as a child of
xsl:apply-templates or xsl:for-each to first sort some node set and then
process it. So sorting is certainly possible in XSLT:
<http://www.w3.org/TR/xslt#sorting>

But as said, XSLT does not include "displaying" anything or showing
controls like a button, that is something a browser does when rendering
HTML documents.

If you want to have a button control in a HTML document displayed in a
browser trigger some sorting then you have the usual possibilities HTML
form controls offer, you can use a HTML form element with some action
URL on a server so that the browser sends a request to that URL on the
server and server-side you run an XSLT transformation with the sorting
and send the resulting HTML document back to the browser.

In browsers that support scripting and dynamic DOM manipulation you
could also consider doing the sorting client-side with JavaScript, but
that task is then usually independent of XSLT but simply an enhancement
of the HTML document which is the result of the XSLT transformation.

Finally a few browsers (Mozilla since 1.2, IE 6, or IE5/5.5 when MSXML 3
is installed) support client-side XSLT and expose an API to script to do
that, in these browser it might also be possible to perform the
transformation client-side and have a button call a script then runs a
transformation to then replace parts of the rendered document with the
sorted result of the transformation.
However, I would like to bundle everything into one file (so that it
can easily be moved or e-mailed) and was hoping that someone can tell me
if/how this can be done.

In theory a XML document can contain the XSLT stylesheet inline, see
<http://www.w3.org/TR/xslt#section-Embedding-Stylesheets> but not any
XSLT processor supports that.
 
A

Alan Searle

Hallo Martin,

Many thanks for your tips and URL links.

This will certainly get me moving.

Regards,
Alan Searle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top