[Tutor] More and more OT - Python/Java

Yigal Duppen yduppen at xs4all.nl
Wed Jan 12 10:15:19 CET 2005


On Wednesday 12 January 2005 00:34, Max Noel wrote:
> > 	As a bonus, I've decided to have a look at XSL, which allows me to
> > format a XML file for display in a web browser. It entirely changed my
> > perception of web programming.
> > 	I intend to program an on-line browser-based game with some friends
> > of mine later in the year (in Python of course -- I converted them),
> > and now that I've seen what XML and XSL can do, we're so going to use
> > them for data output: the data is in dynamically-generated XML, which
> > links to a (static) XSL stylesheet to tell the browser how to render
> > that data.

Hi Max,

While I agree that the XML + XSL -> HTML architecture *sounds* very nice, in 
real life it's not so sweet. I've worked on some projects that used this 
approach and IMHO, the biggest problem is the debugging of XSL output -- XSL 
scripts are a horror to read, and the complex matching rules often make it 
very hard to discover which template caused which error. 

In this case I'd suggest a templating language, such as TAL (part of Zope, 
http://www.zope.org) or a different language. 

At my work (Java) we now use JSP, a Java templating language; debugging time 
has significantly decreased by using this instead of XSL. 

> > 	Doing things that way has many advantages:
> > 1) Data is separate from formatting. That's always a Good Thing(TM).
> > If I someday decide that I don't like the way the site looks, I
> > theoretically only need to recreate a stylesheet, without touching
> > anything else. (boom! Instant skins!)

You're completely right, but as I pointed out, XSLT is not the only option.

> > 2) Most of the "HTML rendering" is going to be done by the user's
> > browser. This, and the way XSL stylesheets are constructed will
> > prevent many bad HTML issues.

HTML rendering is usually not an issue for web-based programs. And if it is, a 
bit of front-end caching usually can save a lot more time. After all, whether 
you have to render HTML or XML, you do have to render something. 

As for the bad HTML issues, the same issues (unclosed tags, wrong attributes) 
do exist when rendering XML. 

> > 3) For the same reason, it will save bandwidth. The XML data will
> > probably take less space than the fully-formatted stuff I'd have to
> > spit out with "regular" HTML, and the XSL stylesheet can probably be
> > cached by the user's browser.

As Alan pointed out, this might very well not be true :-)

> > 4) In the same line of reasoning, it'll also save CPU time: XML data,
> > being smaller, is generated faster than the equivalent HTML. Granted,
> > the stylesheet is another server request, but it's static, so it puts
> > virtually no load on a server.

My answer to this is the same as nr 2. 



Yigal



More information about the Tutor mailing list