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.
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:
- I learned this stuff at University about a million years ago and I wondered if these skills were still relevant (they aren't!)
- Browsers are constantly deprecating old features. I wanted to see if XML & XSL still worked (they do!)
- 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!
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.
Dan Jacob said on masto.ai:
@Edent been a long time since I've looked at XSLT.
Tane Piper said on tane.codes:
@Edent I always like to imagine there's a world where XSLT won, we improved it and never built SPAs.
Doug said on union.place:
@tanepiper @Edent 100%. funny "we" gave up on XSLT at version 3, yet new frameworks get a new chance to fix themselves every 6 months to a year.
Sue Smith said on glasgow.social:
@Edent clicked this hoping to find xslt and was not disappointed 🥳
DamonHD said on mastodon.social:
@Edent hey I write all my source as if XHTML nominally to make it possible to syntax check for all the things without knowing millions of HTML tags' cruft. Not that I do. Then I run my output through vnu for realz!
Dave Smith said on ohai.social:
@Edent There is far too much "JSON is the answer! What was your problem again?" I even used to like SOAP.
Phil Ashby: :marmite:, UBI now said on mastodon.me.uk:
@scudderfish @Edent shudders SOAP. I still have the flashbacks! 🙃
@Edent how about a site that is 100% client side rendered in wasm now that we have a suitable content type..? Flash throwback!
Jackson Palmer 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.
Andy 'Bob' Brockhurst :donor: said on infosec.exchange:
@Edent
#webdev #XML
Oooph. I think about 2001 I wrote an entire api/soap/website admin interface that was entirely xml/xslt.
I'm kinda proud that it worked, but I think as soon as I left they probably killed it because it was just way too difficult to maintain long term. webdev xml
Mark Johnson said on ubuntu.social:
@Edent When I started working there, oss-watch.ac.uk was XML (specifically TEI). I got fed up with it and wrote a TEI-to-Markdown converter, which used XSLT plus some scripts to tidy things up.
Ben Curthoys 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.
Ben Curthoys 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.
Spooky witch 🧙♀️ Sarah said on hachyderm.io:
@Edent posts like these make me check HTML’s acknowledgment page, there’s still only one Sara(h) on that page 😕
Colin Cogle 🔵 said on mastodon.social:
@Edent @divclassbutton I was about to say you could style an RSS feed, for any humans that stumble across it, but you’ve thought of everything.
David O'Brien 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
FeralRobots said on mastodon.social:
@Edent <slow-clap />
Karl Austin said on tweep.uk:
@Edent my dissertation, "Scalable software design with specific reference to web hosting automation" used XML and XSLT to convert config data to app conf files e.g. Apache conf, nginx conf depending on the desired output.
Tommy Carlier says:
You don't even need XSLT: you can use CSS to style XML without having to transform your XML into HTML., using
See https://www.educba.com/xml-with-css/ for an explanation.
Boaty McBoatface says:
just because you can do things doesn't mean you should. like an a-bomb, you know?
More comments on Mastodon.