Tuesday, June 20, 2006


EJAX page formatting

It's satisfying that my vapour ware already made it to the top 15 in Google. These guys are fast!

Let me discuss one of the design choices I've made. There are two ways to get at output a browser understands: the final HTML. One is to let an XSL style sheet generate it (or an Eiffel program, that's all the same), and the other is to take an existing HTML file and modify it before sending it to the browser.

The latter approach is superior for more general purpose toolkits. You can let a designer create the layout, and you only replace portions of the page that have to come from a database.

The RICO guys had a really simple, and therefore smart, way of doing that: if an HTML element has an id, you can replace it's contents with something else. That's the approach I'm using. You just put a div or span somewhere, give it an id. That's all the designer needs to do. The page formatter takes the HTML page and replaces the contents of an element with the contents found in another XML file. Simple, predictable, powerful.

The "two approaches" are identical.

The whole point about XSLT is it is a templating language.
Colin, making such an extreme statement to make your point actually obscures your point. The two approaches are hardly identical even if they both use a templating language.

Berend, I disagree with your statement that the approach you have chosen is superior.

Perhaps it is appropriate for a simple set of relatively simple pages where most of the content is static with only a few "dynamic" pieces that must be filled in and you are working with a designer who knows HTML but not XSLT and the designer won't learn XSLT.

However, having the Eiffel application generate the content (as XML) and then using XSLT to render the final pages (the approach used by the Goanna Application library) has many advantages.

Generating content on the Eiffel side means that you have the full expressiveness of Eiffel (especially inheritance and polymorphism) to reuse that content. With static html pages you are limited to more primitive and awkward content reuse techniques such as server side includes.

Mixing content and markup in an html file will be problematic in a multi-lingual system because you'll need an html file for each language. Making a change to the markup will require changing each html file. In contrast, placing the content in an Eiffel MESSAGE_CATALOG object which can be varied polymorphically and then generating the markup through a single XSLT is much cleaner.

As you know, XSLT is a powerful templating language purpose built for transforming XML to HTML. It gives you a lot more capability for generating mark-up then just simple fill-ins. OK, the syntax sucks (compared to lovely Eiffel) but XML syntax is still better than html.
Neal, I think a lot of pages would require a lot of XSLT coding to get right, and in my experience you just end up putting the HTML in the XSLT style sheet anyway and inserting specifics at various points.

Changing things also requires XSLT knowledge. Many more people can edit an HTML than an XSLT file. Good for maintenance as these things can be handed over to juniors.
Why not join efforts into one framework, i.e GOANNA?
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?