Codingdomain.com

Managing web site content with XML

Introduction

Many static web pages are generated with PHP and MySQL. Static content can also be stored as XML, which is what this site does.

I wouldn't recommend this to anyone. It was however, a fun experiment.

This allowed me to...

Putting it together

The contents of this site is written in pure XML. Instead of using the standard HTML tags, any tag names can be chosen. These tags are converted to the final HTML page with use of XSL. XSL is a XML-transformation language.

A small example

Let's take the following page:

A sample page:
<?xml version='1.0'?>
<page>
  <meta>
    <title>Managing web site content with XML</title>
    <author>Diederik van der Boor</author>
    <created>19 september 2005</created>
    <modified/>
    <abstract>A different way to create web pages with XML.</abstract>
  </meta>

  <section>
    <title>Introduction</title>
    <par>
      Many static web pages are generated with PHP and MySQL.
      Static content can also be stored as XML,
      which is what this site does.
    </par>
  </section>
</page>

this entire article is written that way.

Adding some ingrediets

Linux scripting
The Makefile of this web site currently works in Linux only. It's each to create a file (or script) that supports other platforms as well though.

To HTML is generated by:

And finally, the web site is styled with a CSS stylesheet.

Inventing new tags

The beauty of this system is inventing new tags. For example:

<par>
  The <file>Makefile</file> runs <command>xsltproc</command> to start the conversion.
</par>

<image src="conversion-small.png" largesrc="conversion.png" width="200" height="150" alt="">A caption</image>

<shell title="Uploading data">make upload   <comment># sends the files</comment></shell>

This saved me a lot of headaches in a WYSIWYG editor ;-)

Unfortunately, getting from here to an interactive site is challenging - not impossible however, mind you!

Therefore, my next version will be written in Django. It's a good tool for meshing concepts together, in a consistent look.

blog comments powered by Disqus