Can I use an xslt stylesheet to update a web page?

Discussion in 'Javascript' started by Matt Silberstein, Apr 25, 2006.

  1. I have a data intensive web app I am developing. The core of the app
    will do a db query and build a page. I plan on getting the data as xml
    and feeding that and a xslt stylesheet to the browser. Here is my
    question: the user can the request more data. I would like to somehow
    use the same (or a version thereof) stylesheet to transform this new
    data. But this is added to the existing page, not replacing it. Is
    there a simple way to do this?

    TIA.

    --
    Matt Silberstein

    Do something today about the Darfur Genocide

    http://www.beawitness.org
    http://www.darfurgenocide.org
    http://www.savedarfur.org

    "Darfur: A Genocide We can Stop"
    Matt Silberstein, Apr 25, 2006
    #1
    1. Advertising

  2. Matt Silberstein

    Andy Dingley Guest

    Matt Silberstein wrote:

    > But this is added to the existing page, not replacing it.


    What does "added to the existing page" mean?

    This is the web. HTTP works so that you get a new page (which might be
    bigger) and although it _looks_ like "the old page with things added to
    it", it's actually a whole new page made of entirely new bits and
    bytes. So from the traditionalist HTTP view, your request is
    impossible because HTTP just doesn't work like that.

    For good efficient design, you should look at caching the stylesheet on
    the server though - that's certainly worth doing.


    However your request is a reasonable one and these days it's
    increasingly possible. Look at using AJAX for a way that really is
    "adding to the existing page". This depends on client-side scripting
    though.
    Andy Dingley, Apr 25, 2006
    #2
    1. Advertising

  3. On 25 Apr 2006 02:43:04 -0700, in comp.text.xml , "Andy Dingley
    <>" <> in
    <> wrote:

    >
    >Matt Silberstein wrote:
    >
    >> But this is added to the existing page, not replacing it.

    >
    >What does "added to the existing page" mean?
    >
    >This is the web. HTTP works so that you get a new page (which might be
    >bigger) and although it _looks_ like "the old page with things added to
    >it", it's actually a whole new page made of entirely new bits and
    >bytes. So from the traditionalist HTTP view, your request is
    >impossible because HTTP just doesn't work like that.
    >
    >For good efficient design, you should look at caching the stylesheet on
    >the server though - that's certainly worth doing.
    >
    >
    >However your request is a reasonable one and these days it's
    >increasingly possible. Look at using AJAX for a way that really is
    >"adding to the existing page". This depends on client-side scripting
    >though.


    I was not clear, sorry. Yes, it is going to be an AJAX app, there is
    lots of JavaScript already. What I wanted was some JavaScript way to
    transform the incoming xml. That way I only need to maintain one codes
    base that turns the data to a displayable form. I can use a xslt
    stylesheet for the initial, but would have to do the update (getting a
    new record, for example) through JavaScript.


    --
    Matt Silberstein

    Do something today about the Darfur Genocide

    http://www.beawitness.org
    http://www.darfurgenocide.org
    http://www.savedarfur.org

    "Darfur: A Genocide We can Stop"
    Matt Silberstein, Apr 25, 2006
    #3
  4. Matt Silberstein wrote:

    > [...] Yes, it is going to be an AJAX app, there is lots of JavaScript
    > already. What I wanted was some JavaScript way to transform the incoming
    > xml. That way I only need to maintain one codes base that turns the data
    > to a displayable form. I can use a xslt stylesheet for the initial, but
    > would have to do the update (getting a new record, for example) through
    > JavaScript.


    <URL:http://xulplanet.com/references/objref/XSLTProcessor.html>
    <URL:http://developer.mozilla.org/en/docs/XSLT>


    HTH

    PointedEars, F'up2 cljs
    Thomas 'PointedEars' Lahn, Apr 25, 2006
    #4
  5. Matt Silberstein

    Andy Dingley Guest

    Nick Kew wrote:

    > An alternative could be content assembly somewhere between the
    > origin and the browser. The idea being that a proxy, or a filter
    > within the server, caches the original contents and adds new
    > contents as necessary.


    I'd be somewhat unhappy about the concepts of "filter" and "adding new
    content" being so closely coupled. I'm happy about filters that
    transcode content or manipulate presentation, but something that adds
    original content of the same order as the initial content ? That
    sounds like a recipe for spaghetti data paths.
    Andy Dingley, Apr 25, 2006
    #5
  6. Matt Silberstein

    Nick Kew Guest

    Andy Dingley <> wrote:
    > Nick Kew wrote:
    >
    >
    >>An alternative could be content assembly somewhere between the
    >>origin and the browser. The idea being that a proxy, or a filter
    >>within the server, caches the original contents and adds new
    >>contents as necessary.

    >
    >
    > I'd be somewhat unhappy about the concepts of "filter" and "adding new
    > content" being so closely coupled. I'm happy about filters that
    > transcode content or manipulate presentation, but something that adds
    > original content of the same order as the initial content ? That
    > sounds like a recipe for spaghetti data paths.
    >

    It's what the OP asked for.

    It's also widely practiced: for example, SSI, XSLT or ESI are
    inherently filters, while JSP, PHP, or any templating system
    are at least *conceptually* the same. Which both supports and
    refutes your point: PHP is the biggest bodge-job, but is not
    in fact implemented as a filter - for reasons that have never
    been clear to me beyond "it breaks" (even more than it's
    already broken).

    Other content assembly happens at the browser - e.g. <img src="...">
    Or at an aggregator. Or ... basically anywhere.

    --
    Nick Kew
    Nick Kew, Apr 25, 2006
    #6
  7. Matt Silberstein

    Andy Dingley Guest

    Nick Kew wrote:

    > It's also widely practiced: for example, SSI, XSLT or ESI are
    > inherently filters, while JSP, PHP, or any templating system
    > are at least *conceptually* the same.


    JSP should (and frequently is) no more than a presentational layer --
    that's what tag libraries are for, and why half-decent Java work makes
    such an effort to separate logic and presentation..

    The biggest difference between JSP and ASP code is that ASP code sucks.
    Not that ASP itself sucks, or that all ASP code sucks - but the general
    working practice of a good JSP shop is encouraged to be good (it's
    those tag libraries, amongst other things), whilst that of ASP is one
    big tarball of mixed logic and presentation. Just go to an ASP
    developer and ask about even something as ancient MVC - they'll just
    stare at you in bafflement.

    It's sometimes said that the only way to make a good ASP coder is to
    teach them JSP first. And the only way to make a decent ASP coder is to
    show them JSP as an example of what's possible and how it ought to be
    structured.

    PHP is, of course, simply beyond the pale.
    Andy Dingley, Apr 25, 2006
    #7
  8. On Tue, 25 Apr 2006 14:44:29 +0200, in comp.lang.javascript , Thomas
    'PointedEars' Lahn <> in
    <> wrote:

    >Matt Silberstein wrote:
    >
    >> [...] Yes, it is going to be an AJAX app, there is lots of JavaScript
    >> already. What I wanted was some JavaScript way to transform the incoming
    >> xml. That way I only need to maintain one codes base that turns the data
    >> to a displayable form. I can use a xslt stylesheet for the initial, but
    >> would have to do the update (getting a new record, for example) through
    >> JavaScript.

    >
    ><URL:http://xulplanet.com/references/objref/XSLTProcessor.html>
    ><URL:http://developer.mozilla.org/en/docs/XSLT>
    >
    >
    >HTH


    Thanks. TranformtoFragment is exactly what I want. Unfortunately it
    looks like that only works for Mozilla/Firefox. So I have to figure
    out something else for IE. I really don't want two pieces of code that
    do the same thing. Maybe I will do the transform on the server for IE.
    Not as clean but I can have just one stylesheet.

    --
    Matt Silberstein

    Do something today about the Darfur Genocide

    http://www.beawitness.org
    http://www.darfurgenocide.org
    http://www.savedarfur.org

    "Darfur: A Genocide We can Stop"
    Matt Silberstein, Apr 25, 2006
    #8
  9. Matt Silberstein wrote:

    > On Tue, 25 Apr 2006 14:44:29 +0200, in comp.lang.javascript , Thomas
    > 'PointedEars' Lahn <> in
    > <> wrote:


    Please trim your attribution to the essentials.

    >> Matt Silberstein wrote:
    >>> [Transform XML markup according to an XSL stylesheet]

    >>
    >> <URL:http://xulplanet.com/references/objref/XSLTProcessor.html>
    >> <URL:http://developer.mozilla.org/en/docs/XSLT>
    >> [...]

    >
    > Thanks. TranformtoFragment is exactly what I want. Unfortunately it
    > looks like that only works for Mozilla/Firefox. So I have to figure
    > out something else for IE. I really don't want two pieces of code that
    > do the same thing.


    I am afraid if you code client-side, you will have to.

    > Maybe I will do the transform on the server for IE.
    > Not as clean but I can have just one stylesheet.


    I am pretty sure MSXML provides a solution for this, both client-side and
    server-side.


    PointedEars
    --
    Germany is the birth place of psychiatry. Psychs feel threatened by
    Scientology as they are crazy. Many psychs become psychs to heal their own
    mental problems and to control others. -- "The only real Barbara Schwarz",
    dsw.scientology, <>
    Thomas 'PointedEars' Lahn, Apr 25, 2006
    #9
  10. Matt Silberstein wrote:

    > TranformtoFragment is exactly what I want. Unfortunately it
    > looks like that only works for Mozilla/Firefox.


    It also works with Opera 9 beta respectively will work with Opera 9 once
    it has been released.

    > So I have to figure
    > out something else for IE. I really don't want two pieces of code that
    > do the same thing. Maybe I will do the transform on the server for IE.


    IE 6 uses MSXML 3 for XML, XSLT and XPath. The API is different from the
    Mozilla API and the implementation is separate from the HTML DOM IE
    provides so you can't create a document fragment of an IE HTML document.
    So usually you will create a string with a HTML snippet and insert that
    into the HTML DOM tree using innerHTML or insertAdjacentHTML.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Apr 25, 2006
    #10
  11. JRS: In article <>, dated Tue, 25
    Apr 2006 19:17:55 remote, seen in news:comp.lang.javascript, Thomas
    'Ludwig II' Lahn <> posted :
    >Matt Silberstein wrote:
    >
    >> On Tue, 25 Apr 2006 14:44:29 +0200, in comp.lang.javascript , Thomas
    >> 'PointedEars' Lahn <> in
    >> <> wrote:

    >
    >Please trim your attribution to the essentials.


    Matt, your attribution is substantially compliant with USEFOR thinking;
    a full attribution is often helpful. Be aware that Thomas Lahn
    evidently has ambitions to lead the Fourth Reich.

    >
    >PointedEars
    >--
    >Germany is the birth place of psychiatry. Psychs feel threatened by
    >Scientology as they are crazy. Many psychs become psychs to heal their own
    >mental problems and to control others. -- "The only real Barbara Schwarz",
    >dsw.scientology, <>


    (1) Non-compliant with RFC1855.
    (2) Given your personal condition, don't you consider it unwise to
    introduce the subject of German psychiatry?

    --
    © John Stockton, Surrey, UK. yyww merlyn demon co uk Turnpike v4.00 MIME ©
    Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
    Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
    No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
    Dr John Stockton, Apr 26, 2006
    #11
    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. =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=

    Stylesheet referanse i stylesheet

    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=, Jul 3, 2004, in forum: XML
    Replies:
    3
    Views:
    561
    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=
    Jul 4, 2004
  2. Steven An
    Replies:
    1
    Views:
    490
    Martin Honnen
    Nov 23, 2004
  3. David Blickstein
    Replies:
    3
    Views:
    1,024
    David Blickstein
    Aug 2, 2005
  4. David Blickstein
    Replies:
    14
    Views:
    6,304
    Harrie
    Oct 16, 2005
  5. Replies:
    3
    Views:
    354
Loading...

Share This Page