Alazanto

A Small Demonstration

Filed Under: MT Carbon, Journal.

Today, I have a small demonstration.

Small - seeing that I’m unsure how to tie the XML and XSLT together with PHP using the DOM XML Extension installed on my host’s server(s).

On to the show!

Let us suppose that I created a new weblog. Now, let us also assume that I really don’t feel much like producing a design (beyond that of what movabletype, or another blogging program, offers as a default). What I could do, is acquire a series of XML templates, install them into my blogging system, then simply link those XML templates to a “theme” of my liking.

The following link will point you towards this blog’s index, encoded in XML and using (what is similar to) a default movabletype layout.

alazanto.org/xml/index.xml

What makes this thing so special?

Movabletype outputs this particular page to pure XML (extensible markup language). This data can be ported to any source you like. For instace, with the advent of RSS, custom applications are being produced simply to read the RSS data and present it in a user friendly manner. The showcased XML document is linked to an XSLT (extensible stylesheet language tranformations) document. This document reads the XML data and transforms it into something that a web browser (in our case, IE6, Netscape 6+, Mozilla) can read. In turn, the XSLT document is linked to a CSS (cascading style-sheet) document which defines font-sizes, background images and other superficial (but important) styling.

Well, I don’t know about you, but, even though I like the black, I’m not a very big fan of the overall layout. Because of this, why not link the XML document to XSLT/CSS stylesheets which may be more to our liking?

carbon copy of alazanto.org
alazanto.org/xml/style2.xml

carbon copy of mezzoblue.com (acquired with permission)
alazanto.org/xml/mezzo.xml

Or, how about…

carbon copy of my zen garden submission
alazanto.org/xml/style3.xml

For the latter page layout, I hacked Dave Shea’s beautiful markup to pieces in order to bring you an alternative rendition of my css zen garden submission. :) However, I didn’t even touch the CSS document, except to bring basic formatting to undefined headers.

In all these examples, I have linked to different XML documents. Each of these documents are identical, except for the following:

<?xml-stylesheet type=\"text/xsl\"href=”pick_a_stylesheet.xsl”?>

Let us now assume that someone else wanted to start their own weblog, but did not want to spend their time writing custom markup or sculpting css. All they would need to do is implement the standard XML movabletype templates, link those XML documents to the URL of their desired XSLT stylesheet, and viola!

alazanto.org/xml2/index.xml

Instant layout in a can.

The importance of such a methodology may be:

  • To give folks who are new to blogging a chance to apply some really neat designs to their blog without the need for CSS or HTML skills.
  • Commercial or Organizational sites could let the user apply common “themes” in order to aid usability and increase uniformity.
  • Independent Media sites, especially those operating under a confederal system, could use one centralized “theme” - one which could be updated for handicap accessibility, validation, or appearance by one individual or team. With small budgets, they could spend their resources on more important matters.

And so, I leave you with my current state of progress. Now for a couple of open requests.

  • The client side parser in IE6 is able to understand the disable-output-escaping=”yes” expression. However, in mozilla this does not work, causing HTML embedded in the XML documents not to be rendered. Is there a way to get mozilla to render embedded markup?
  • I am also looking for friendly assistance in merging these documents using the PHP DOM XML Extension. I can do it using sablotron, but this parser seems like a completely different animal.
  • I should include one additional note. Dave Shea was able to help me through some earlier problems I was having with Mozilla. It seems that mozilla requires the document-type to be text/xml in XML and XSL documents. The two formats will not allow you to specify this information in the document itself, so you will need to modify your HTTP headers. For apache users, this couldn’t be easier.
  • In your http.conf or .htaccess (something I spoke about in an earlier post) simply add the following line:
  • AddType text/xml .xml .xsl

    The server will automatically give XML and XSL documents a document-type of text/xml.

Published: 5 years ago