dynamic sorting

Discussion in 'XML' started by Alan Searle, Nov 10, 2005.

  1. Alan Searle

    Alan Searle Guest

    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)
     
    Alan Searle, Nov 10, 2005
    #1
    1. Advertising

  2. Alan Searle wrote:

    > 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.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Nov 11, 2005
    #2
    1. Advertising

  3. Alan Searle

    Alan Searle Guest

    Hallo Martin,

    Many thanks for your tips and URL links.

    This will certainly get me moving.

    Regards,
    Alan Searle
     
    Alan Searle, Nov 11, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jordo
    Replies:
    0
    Views:
    469
    Jordo
    Oct 31, 2003
  2. Replies:
    2
    Views:
    1,489
    James Kanze
    Jul 6, 2010
  3. Jason
    Replies:
    0
    Views:
    410
    Jason
    Oct 4, 2006
  4. Tom Kirchner

    sorting by multiple criterias (sub-sorting)

    Tom Kirchner, Oct 11, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    509
    Michael Budash
    Oct 11, 2003
  5. Íéêüëáïò Êïýñáò

    Sorting a set works, sorting a dictionary fails ?

    Íéêüëáïò Êïýñáò, Jun 10, 2013, in forum: Python
    Replies:
    12
    Views:
    169
    Ulrich Eckhardt
    Jun 10, 2013
Loading...

Share This Page