Ajax with XML and XSL

Discussion in 'Javascript' started by bcochofel, Dec 14, 2006.

  1. bcochofel

    bcochofel Guest

    Hi, I want to update part of a XML output (generated by Perl CGI). I'm
    using XSL to transform the XML.

    Can I use this approach?

    I need to resort the contents of a table, that gives me the results
    from a query, when someone clicks on one of the names of that table.

    Thanks,
    Bruno
    bcochofel, Dec 14, 2006
    #1
    1. Advertising

  2. bcochofel wrote:

    > Hi, I want to update part of a XML output (generated by Perl CGI). I'm
    > using XSL to transform the XML.
    >
    > Can I use this approach?
    >
    > I need to resort the contents of a table, that gives me the results
    > from a query, when someone clicks on one of the names of that table.


    Several approaches are possible:

    - XSL: not my favourite, browser dependencies, client side
    - TDC: only for Internet Explorer, handy, quick, propietary, the same
    concept as eg VBScript, MS Help Viewer, ActiveX, etc.
    - Perl: XML::Simple/XML::parser, server side, low client requirements,
    solid
    - Ajax: probably okay

    --
    Bart
    Bart Van der Donck, Dec 14, 2006
    #2
    1. Advertising

  3. bcochofel

    bcochofel Guest

    I'm working with Linux, so no TDC...
    I have to work only on the client side, but without XSL (I don't know
    how to use XSL on the client...)
    I guess I'll have to stick with Ajax. My problem his: How can I read
    the elements from the XML? DOM? Don't know much about DOM.

    Can I save the elements (using DOM) to an array in Javascript so them I
    can resort whatever I want?

    Bart Van der Donck wrote:

    > bcochofel wrote:
    >
    > > Hi, I want to update part of a XML output (generated by Perl CGI). I'm
    > > using XSL to transform the XML.
    > >
    > > Can I use this approach?
    > >
    > > I need to resort the contents of a table, that gives me the results
    > > from a query, when someone clicks on one of the names of that table.

    >
    > Several approaches are possible:
    >
    > - XSL: not my favourite, browser dependencies, client side
    > - TDC: only for Internet Explorer, handy, quick, propietary, the same
    > concept as eg VBScript, MS Help Viewer, ActiveX, etc.
    > - Perl: XML::Simple/XML::parser, server side, low client requirements,
    > solid
    > - Ajax: probably okay
    >
    > --
    > Bart
    bcochofel, Dec 14, 2006
    #3
  4. bcochofel

    Dag Sunde Guest

    bcochofel wrote:
    <snipped/>
    > I'm working with Linux, so no TDC...
    > I have to work only on the client side, but without XSL (I don't know
    > how to use XSL on the client...)
    > I guess I'll have to stick with Ajax. My problem his: How can I read
    > the elements from the XML? DOM? Don't know much about DOM.
    >
    > Can I save the elements (using DOM) to an array in Javascript so them
    > I can resort whatever I want?
    >


    That's what I would have done...

    Loop through the DOM to build your JS array, and build your table
    from that.
    Each time the user clicks on a column heading, resort the array
    and rebuild your table from JS.

    --
    Dag.
    Dag Sunde, Dec 15, 2006
    #4
  5. bcochofel

    bcochofel Guest

    My problem his that I have to use XSL on the server side to generate
    the table.
    Maybe after that I can create the JS array but I'll have something like
    this (in XML):

    <?xml version="1.0" encoding="iso-8859-1"?>
    <?xml-stylesheet type="text/xml" href="RR.xsl"?>
    <!-- $Id: template.xml,v 1.5 2006/12/11 11:13:30 bcochofel Exp $ -->
    <RR
    xmlns:xsi="http://www.w3.org/2001/XMLSchema"
    xsi:schemaLocation="http://cochofel.sytes.net
    ~bcochofel/iweb/files/RR.xsd">
    <Request>
    <url>/~bcochofel/iweb/cgi-bin/getmysites.cgi</url>
    <session>
    <user></user>
    </session>
    <query>
    <!-- o campo parametro pode ter varias ocurrencias -->
    <param name="sort" value="asc" />
    <param name="field" value="" />
    </query>
    </Request>
    <Response>
    <sites>
    <site url="http://www.google.com">
    <tag name="pesquisa" weight="30" />
    <tag name="procura" weight="30" />
    </site>
    <site url="http://www.google.com/webhp?complete=1">
    <tag name="ajax" weight="25" />
    <tag name="pesquisa" weight="30" />
    <tag name="procura" weight="30" />
    </site>
    <site url="https://webmail.fe.up.pt">
    <tag name="email" weight="20" />
    <tag name="feup" weight="20" />
    </site>
    </sites>
    </Response>
    </RR>

    So <site> can have several <tag> elements.
    How can I create an array with JS like this? I want to sort by
    site[@url] attr, tag[@name], or tag[@weight]...

    Dag Sunde wrote:

    > bcochofel wrote:
    > <snipped/>
    > > I'm working with Linux, so no TDC...
    > > I have to work only on the client side, but without XSL (I don't know
    > > how to use XSL on the client...)
    > > I guess I'll have to stick with Ajax. My problem his: How can I read
    > > the elements from the XML? DOM? Don't know much about DOM.
    > >
    > > Can I save the elements (using DOM) to an array in Javascript so them
    > > I can resort whatever I want?
    > >

    >
    > That's what I would have done...
    >
    > Loop through the DOM to build your JS array, and build your table
    > from that.
    > Each time the user clicks on a column heading, resort the array
    > and rebuild your table from JS.
    >
    > --
    > Dag.
    bcochofel, Dec 15, 2006
    #5
    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. Karsten Weinert
    Replies:
    3
    Views:
    1,007
    Karsten Weinert
    Jul 5, 2004
  2. Vijay singh
    Replies:
    1
    Views:
    435
    Martin Honnen
    Nov 4, 2004
  3. Replies:
    1
    Views:
    3,600
    A. Bolmarcich
    May 27, 2005
  4. minnie
    Replies:
    1
    Views:
    685
    Andrew Thompson
    Dec 13, 2006
  5. bcochofel

    XML and XSL with Ajax

    bcochofel, Dec 14, 2006, in forum: XML
    Replies:
    1
    Views:
    399
    Andy Dingley
    Dec 14, 2006
Loading...

Share This Page