Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Separating form and function on the web using XML and XSLT

created by Peej

(idea) by Peej (11.8 mon) (print)   ?   (I like it!) 2 C!s Thu Aug 02 2001 at 11:10:24

XML is a latest buzzword on the Internet and the Web. Crowned as the future mark-up grammar for information exchange, XML is already being put to use in an astonishing number of applications.

XML's goal is to provide a universal mark-up grammar to define the meaning of data, with a view of using it to replace HTML on the web with a more meaningful and data orientated mark-up (often synonymous with the semantic web or the information web). However XML is still in it's infancy when it comes to server/client interaction via an HTTP server and a web browser, the XML specifications and client browsers are not mature enough for the daily use of XML for web pages. However, there are ways we can use XML on the web today to improve the way we write web applications, by using XML and XSLT to provide an abstraction layer between form and function.

With a server side scripting engine (like PHP, Perl or ASP), an XML parser (like Expat, libxml or MSXML), and an XSLT processor (like Sablotron or MSXSL), you can use XSLT to define your form and XML as an output of your function.

It works something like this. When a HTTP request comes to your HTTP server for a certain piece of information, the scripting engine is invoked which fetches the required information from your database. The information is then used to generate an XML document in memory, which in turn is passed through the XSLT processor and transformed into HTML via the format definition in the XSL stylesheet. This HTML is then sent to the client as an HTTP response.

By using this approach, the functionality of the web application generates a standard XML document (the definition of you define previously) holding pure information, and the presentation of this information is stored separately and applied to the information just before sending it to the client.

The advantages of this technique are numerous, but include:

The disadvantages are of course the overhead of doing the XSL translation, however this is probably very small when compared to database access and script processing time (of course it depends on the speed and efficiency of the XSLT processor).

I have implemented the above web application architecture using both PHP/Sablotron and ASP/MSXSL and have been very impressed with how easy the extraction of form and function is to achieve and work with. I'd recommend this technique to anyone starting a complex web application where separating form and function is important, or to anyone wanting to learn more about XML and XSLT.

printable version
chaos

XSLT Semantic Web Perl PHP
Notelet Nodelet Chatterbox Client If cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl XML web browser
New Writeups RSS Feed HTML E2 Chatterbox Archive model
grammar separation function form
Template scripting expat XML parser
ASP Script Syndication markup
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Nodes to live by:
Node for the Ages
satellites fallen from grace
Reclaim The Streets, London May 1st 2000
Giant Squid Party Platform
Freelance Contract
Thinking without language
How to write poetry
The Amityville Horror
The truth about SUVs
Helping someone who practices self-mutilation
Jump the shark
Maine Coon
In the Aeroplane Over the Sea
New Writeups
Panda_Pain
Write Ups(idea)
sam512
halfway homes, catacombs, twilight zones(fiction)
Timeshredder
The Texas UFO Crash of 1897(event)
Heitah
The Dark Knight(review)
ignis_glaciesque
Uppsala(place)
ignis_glaciesque
diffusion of responsibility(idea)
TheOrientalAfrican
The Soft Meadow of my Childhood(event)
BookReader
The Dragon Slayers(fiction)
kohlcass
religiously fashionable(review)
Pavlovna
waulking song(thing)
tentative
Stick Man(poetry)
Ereneta
The Fight with the Snapping Turtle: Or, the American St. George(poetry)
sitaraika
Fog and fire(personal)
MonoliTheory
She sobs in response(fiction)
kohlcass
Arzu(person)
This affordable entertainment brought to you by The Everything Development Company