Let's build a website using XML!


It is 2023. XHTML is dead and buried. HTML is a "living standard" with billions of users. So what kind of idiot would want to build a website using XML?

Me. I am that idiot.

Last year, I launched a "web page" which didn't use HTML. Called, appropriately enough, "YOU DON'T NEED HTML!" That (ab)used Unicode to make a somewhat attractive page. This year, I decided to forego the Unicode silliness and use XML silliness instead.

Demo

Visit https://xml.viii.fi/index.xml and see for yourself. Take a look at the source-code to verify that it is, indeed, an XML document.

Screenshot of some XML code.

All modern browsers should be able to render it. If you spot any glitches - please let me know.

Why

Because I can 😂

OK, there were three main reasons:

  1. I learned this stuff at University about a million years ago and I wondered if these skills were still relevant (they aren't!)
  2. Browsers are constantly deprecating old features. I wanted to see if XML & XSL still worked (they do!)
  3. The voices in my head told me to (they didn't!)

As an additional bonus reason - I'm bemused by the number of pages which are basically JSON files with client side Javascript rendering. So I thought I'd go old-skool and have the client rendering done without any JS!

Bonus bonus reason - semantics!

Popular meme format. A young man points at a butterfly and says "Is this the semantic web?"
The butterfly is labelled "XML + XSLT".

How

Regular readers will recall that I wrote about how to style your WordPress Atom feed. The technique is pretty simple: take a well-formed XML document and link it to an XSL stylesheet, et voilà there's a beautifully rendered document in your browser.

For this demo, I didn't bother with a proper document schema. I just bashed some random elements together.

The XSL tells the browser to render it as HTML and provides a scaffold for doing so.

It is all gussied up with some fairly generic CSS.

And that's it really.

I'm delighted that this technique still works. I don't think you should use this unless you absolutely need a lightweight way to render XML directly.


Share this post on…

19 thoughts on “Let's build a website using XML!”

  1. said on mastodon.social:

    @Edent I recently went down this rabbit hole and there are too many inconsistencies between browsers and how they handle it. You need special headers for mobile Safari, and sometimes anchors won’t work in Firefox. Firefox also doesn’t support the “disable-output-escaping” feature all other browsers do.

    Neat hack/curiosity, but I’d never use it in production.

    Reply | Reply to original comment on mastodon.social
  2. said on mastodon.social:

    @Edent My software makes heavy use of XSL - generating reports and emails.

    If you use a FOR XML query you can get complicated, nested data out of a SQL server database in a single query. And then an XSL Transform and some libraries can turn that into a spreadsheet, pdf, html, JSON feed, etc.

    So I frequently have occasion to curse the fact that Microsoft never got round to supporting XSLT 2. Bastards.

    Reply | Reply to original comment on mastodon.social
  3. said on mastodon.social:

    @Edent FWIW there was a phase about 10 years ago when Blizzard's WoW Armoury website served pure XML with a stylesheet to render it. It was like the API endpoint /was/ the website. Only major site I've ever seen that actually used the technology.

    Hey did anyone invent an XSL analogue for JSON yet? I bet that would go down a storm.

    Reply | Reply to original comment on mastodon.social
  4. said on mastodon.social:

    First website I built (using a CMS called Obtree) was 2008/9 when XHTML was the standard.

    Site was about 2,000 pages which we whittled down, after much mud-wrestling, to ~600.

    Friggin' nightmare. Had to run every single page through a parser before publishing.

    And, of course, being XML, it just threw the dummy at error 0.

    So you just had to fix each missing / or whatever and do it again, and again until you got zero errors.

    @Edent

    Reply | Reply to original comment on mastodon.social
  5. Boaty McBoatface says:

    just because you can do things doesn't mean you should. like an a-bomb, you know?

    Reply

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">