[thelist] Total separation of content and presentation
Sam Foster
sam at sam-i-am.com
Wed Jan 12 14:54:17 CST 2005
Rosalie Sennett wrote:
> So a storage facility like a database or a templated marked up version of
> the content (in XML) would separate out the two elements. (XML might be
> overkill in this case or may be more work than not if the learning curve is
> introduced)
I've been mulling over the same problem for a while. I reasoned, why
markup my content in XML when XHTML is a perfectly acceptable tag set
for most (and my) purposes. XHTML was created for just this reason -
making the well-known HTML language an XML language opens the door to
using all the XML family of tools: DOM, XSLT etc.
So one way of approaching this is to markup your content in plain
vanilla, semantic html. Then your presentation might be in XSLT, which
matches on the tags in the content (and some id attributes can make life
easier here) and inserts that content into a richer/more complex HTML
output. This moves your presentation logic into XSLT where it belongs.
I like the Handler model that apache provides, so I've been working on a
text/html handler that takes any request for an html file and passes it
to my cgi/php script. The script might do a template look-up, resolve
the URL to a filename and transform the contents of that file with your
XSLT stylesheet, returning the result to the browser.
In practice I find it useful to do some pre-processing of the html -
adding in includes, etc, before transforming. There's also the
opportunty to post-process.
I've found that while most agree that coding in XHTML is preferable, few
really know why, beyond a general sense of standards being a good thing.
XHTML opens these kind of opportunities - you can query, transform and
re-present your content for different devices, browsers, designs,
preferences, contexts.
Sam
More information about the thelist
mailing list