xslt: sorting on the client side - cross browser!

Discussion in 'XML' started by Ben Fitzgerald, Oct 2, 2003.

  1. Hi

    I feel I'll be asking for someone to turn water into wine
    before this happens, but just in case!

    I'd like to have a page that provides a basic xml document
    with an xslt that defines the default sorting. Say it's in
    a table sorted by name with columns age and height.

    Then, when the user clicks on another column heading, this
    kicks of a (perhaps javascript) call to change the xslt
    sort parameter and reformat the page. This would all take
    place on the client side, and work on mozilla 1.3 and IE5.5
    and higher.

    Is this possible? I realise it's a big ask!!

    Right now I'm still hoping against hope.

    Someone put me out of my misery. ;)

    Thanks,

    Ben
    Ben Fitzgerald, Oct 2, 2003
    #1
    1. Advertising

  2. Re: sorting on the client side - cross browser!

    Pass the name of the sort column and the sort order and the datatype of the
    sort field as parameters to the xslt transformation,

    See for example:
    http://www.dpawson.co.uk/xsl/sect2/N6461.html#d6859e950


    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL


    "Ben Fitzgerald" <> wrote in message
    news:...
    > Hi
    >
    > I feel I'll be asking for someone to turn water into wine
    > before this happens, but just in case!
    >
    > I'd like to have a page that provides a basic xml document
    > with an xslt that defines the default sorting. Say it's in
    > a table sorted by name with columns age and height.
    >
    > Then, when the user clicks on another column heading, this
    > kicks of a (perhaps javascript) call to change the xslt
    > sort parameter and reformat the page. This would all take
    > place on the client side, and work on mozilla 1.3 and IE5.5
    > and higher.
    >
    > Is this possible? I realise it's a big ask!!
    >
    > Right now I'm still hoping against hope.
    >
    > Someone put me out of my misery. ;)
    >
    > Thanks,
    >
    > Ben
    Dimitre Novatchev, Oct 3, 2003
    #2
    1. Advertising

  3. Ben Fitzgerald

    Wired Earp Guest

    Re: sorting on the client side - cross browser!

    Dimitre Novatchev wrote:

    > Pass the name of the sort column and the sort order and the datatype
    > of the sort field as parameters to the xslt transformation,
    >
    > See for example:
    > http://www.dpawson.co.uk/xsl/sect2/N6461.html#d6859e950
    >
    > "Ben Fitzgerald" wrote
    >> ...Then, when the user clicks on another column heading, this
    >> kicks of a (perhaps javascript) call to change the xslt
    >> sort parameter and reformat the page. This would all take
    >> place on the client side, and work on mozilla 1.3 and IE5.5
    >> and higher.


    You'll also need the Mozilla XSLT javascript interface
    <url:http://www.mozilla.org/projects/xslt/js-interface.html>
    and the Mozilla DOMParser [for translating XSLT output to DOM elements]
    url:http://www.xulplanet.com/tutorials/xulqa/q_parsexul.html>

    For passing params to a clientside XSLT transformation in Explorer you
    would require installation of the MSXML toolkit extensions, there's an
    example over at <url:http://msdn.microsoft.com/library/default.asp?
    url=/library/en-us/xmlsdk/htm/xsl_interactive_9zeb.asp>. No DOMParser
    available for Explorer, you'll need to update the page using innerHTML.



    --
    Wired Earp
    Wunderbyte
    Wired Earp, Oct 3, 2003
    #3
  4. Re: sorting on the client side - cross browser!


    > For passing params to a clientside XSLT transformation in Explorer you
    > would require installation of the MSXML toolkit extensions, there's an
    > example over at <url:http://msdn.microsoft.com/library/default.asp?
    > url=/library/en-us/xmlsdk/htm/xsl_interactive_9zeb.asp>.


    This link is to an example of using MSXML in ASP.

    Passing external parameters to an MSXML transformation is most easily
    accomplished using the IXSLProcessor.addParameter() method.

    The place to read about this is the MSXML4 or MSXML3 SDK documentation.


    =====
    Cheers,

    Dimitre Novatchev.
    http://fxsl.sourceforge.net/ -- the home of FXSL
    Dimitre Novatchev, Oct 3, 2003
    #4
  5. Ben Fitzgerald

    Wired Earp Guest

    Re: sorting on the client side - cross browser!

    Dimitre Novatchev wrote:

    > This link is to an example of using MSXML in ASP.


    Notice the <%@LANGUAGE="JavaScript"%> declaration. The javascript part of
    the deal is perfectly valid for clientside operations.

    > Passing external parameters to an MSXML transformation is most easily
    > accomplished using the IXSLProcessor.addParameter() method.


    Which is what the example examplifies.

    > The place to read about this is the MSXML4 or MSXML3 SDK documentation.


    you are right; there is a better example over at
    <url:http://msdn.microsoft.com/library/default.asp?url=/library/en-
    us/xmlsdk/htm/xml_obj_ixslprocessor_9j8y.asp> - at least if you stick to
    the first example on the page.


    --
    Wired Earp
    Wunderbyte
    Wired Earp, Oct 3, 2003
    #5
  6. Ben Fitzgerald

    Wired Earp Guest

    Re: sorting on the client side - cross browser!

    I wrote:

    > there is a better example over at
    > <url:http://msdn.microsoft.com/library/default.asp?url=/library/en-
    > us/xmlsdk/htm/xml_obj_ixslprocessor_9j8y.asp>


    Except that this example doesn't add params. Sorry about the confusement!



    --
    Wired Earp
    Wunderbyte
    Wired Earp, Oct 3, 2003
    #6
  7. Ben Fitzgerald

    Wired Earp Guest

    Re: sorting on the client side - cross browser!

    I wrote:

    > Sorry about the confusement!


    Really digging a hole for myself here, but I would like to draw attention
    away from aforementioned Mozilla DOMParser - you can dump the
    XSLTProcessors output directly into the DOM structure:

    var oSchema = document.implementation.createDocument ( "", "", null );
    var oOutput = document.implementation.createDocument ( "", "", null );
    oTransform.load ( "stylesheet.xsl" );

    // when stylesheet is loaded
    document.documentElement.appendChild
    ( new XSLTProcessor().transformToFragment
    ( this.oSchema, this.oOutput ).firstChild );

    The wonders of Mozilla.


    --
    Wired Earp
    Wunderbyte
    Wired Earp, Oct 3, 2003
    #7
    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.

Share This Page