HACKER Q&A
📣 rsolva

Have you built a website in XML and XSLT?


I have read up a bit on XML + XSLT the last few days, knowing very little about it, and was surprised to learn that it is rendered entirely in the browser without the need for server side processing or JavaScript.

If any of you have made a website using only XML + XSLT – how did you structure the content and what strategies did you use to write and include repeating elements (like header, footer etc)?

Feel free to leave real world examples or write-ups in the comments!


  👤 moistly Accepted Answer ✓
XML and XSLT are still very much in use, especially in Europe and industries where data schematization & long-term retention are important. I’ve written XSLT applications for use in banking, healthcare, technical publishing, and compliance markets.

For you, I recommend checking out the Docbook transformations and Saxon-JS. The former is a tool for publishing technical documentation to HTML, the latter is an compliant XSLT processor implemented in the browser/NodeJS.

XSLT/XQuery/XPath are excellent tools for querying and restructuring tree-structured data. There are a lot of people out there who have very little experience but great big opinions: you should ignore them.

Note that these technologies are functional programming languages. It will likely take some effort to wrap your head around it all. Michael Kay’s book is a good start, but unfortunately is not updated for the v3 spec.


👤 icedchai
XSLT was a fad for a couple years in the late 90's through early 2000's. I briefly worked at a company that used XSLT as part of a content management system. It wasn't good then, and I wouldn't touch it with a ten foot pole now.

👤 gabelschlager
I didn't build it myself, but I maintained one for a while as part of a student job.

The website itself was hosting various resources for researchers, etc. Each resource was annotated via a specific XML format and XSLT was used to dynamically create HTML pages, as well as to transform the XML files into various other file formats.

The by far biggest problem was, and still is, that XSLT is very verbose and not well-maintainable. Small changes here and there were possible, but larger changes almost always required rewriting the entire stylesheet. On top of that, the XML format got bigger and bigger as well (as it was used and modified by Universities across Europe), edge cases were added, etc., that did not help when it came to writing the XSLT stylesheets, but that's a different problem. We also had to switch to XSLT 3.0 at some point and had to render the HTML server-side, since browsers don't support anything beyond XSLT 1.0.

Overall, I still kind of enjoyed working with it. For complex XML, it was by far the easiest way to work with them.


👤 stefanos82
I was as well surprised when I found the NGINX website code was and still is implemented in XML + XSLT and XSLS! Have a look for yourself: http://hg.nginx.org/nginx.org/file/tip

👤 TedDoesntTalk
This is a very old way of building websites. I have not heard of this being done in a very long time. The problem was maintainability of the XSLT sheets. And although you say no server-side processing is needed, the XML was almost always generated server-side from underlying database queries. That’s the only way to make the pages dynamic.

👤 speedgoose
You can skip the XSLT part and use CSS and XML together.