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

M

Matt Silberstein

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"
 
A

Andy Dingley

Matt said:
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.
 
M

Matt Silberstein

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"
 
T

Thomas 'PointedEars' Lahn

Matt said:
[...] 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
 
A

Andy Dingley

Nick said:
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.
 
N

Nick Kew

Andy Dingley said:
Nick Kew wrote:




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

Andy Dingley

Nick said:
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.
 
M

Matt Silberstein

Matt said:
[...] 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"
 
T

Thomas 'PointedEars' Lahn

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

Please trim your attribution to the essentials.

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
 
M

Martin Honnen

Matt said:
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.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Tue, 25
Apr 2006 19:17:55 remote, seen in Thomas
'Ludwig II' Lahn said:
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, <[email protected]>

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

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top