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 (9.8 mon) (print)   ?   2 C!s I like it! 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
After stirring Everything, these nodes rose to the top:
Hieronymus Bosch
octocontrabass clarinet
what all the kids are reading
Unrecoverable Flight Regime
Fallen Angels
Johannes Vermeer
Mustang Ranch
Using Unicode on E2
The Story of the Vivian Girls
MashiMaro
Squirrel
Honor Roll
Guns, Germs, and Steel
New Writeups
jjen
Sorrier than I ever thought I would be(personal)
locke baron
Moskva class antisubmarine cruiser(thing)
Wuukiee
May 15, 2008(idea)
locke baron
Kuznetsov class aircraft carrier(thing)
_lesra
for abby(thing)
Adaptive Child
Annie's garden salsa(recipe)
Simulacron3
Zig-Zag(thing)
Ouzo
Special Grilled Cheese(fiction)
Noung
Tiananmen Square Massacre(idea)
aneurin
Lord St Clair(person)
artman2003
Assholes and Douchebags: A Comparison(person)
locke baron
Tyan Thunder K8WE(thing)
locke baron
Udaloy class destroyer(thing)
Scaevola
Same-sex marriage(idea)
SteveMurrayFromNZ
British Standard Handful(idea)
Everything 2 is brought to you by the letter C and The Everything Development Company