Hacker News new | ask | show | jobs
by Trustable8 45 days ago
Shame back in the XHTML days XSLT was a spec that could have made website modularity so much cleaner. I once created an early website creation tool that merged separate components using XSLT it was really powerful in the days before javascript was usable without jQuery. However XHTML was dropped in favor of HTML5 and XSLT was pretty much useless after that. Its done well to survive this long I presume it was mainly kept to style XML files.
5 comments

HTML5 could have taken the extra step of defining a canonical XML or XML-compatible DOM encoding, or at least encouraged it. But the anti-XML sentiment was explicit and spiteful. Still, popular XSLT processors are built to consume and even produce HTML5, I'm just not sure how thorough those capabilities are or whether they're based on any formal or informal standards. (Maybe the W3C has/had something like that, as part of it's attempts to rollup HTML5 snapshots into versioned standards?)

I lost any enthusiasm for XML after my experience with WDDX and XML-RPC, but as a foundation for HTML it was the best thing going. And maybe still is, given the absence of cross-toolchain contenders? Ditto for XSLT, at least if disregarding the choice to make the syntax homoiconic. In fact I circled back to XSLT long after it was clear it was a dead end. A good tool is a good tool, and the fact it remains so despite the wanton neglect only proves it.

I'm curious, what exactly in the DOM is not XML-compatible?
From long-lost memory, I think it's implicitly closed tags (e.g. img).
That is one, but not the only thing. Non-xml html is just generally more forgiving.

If you make a mistake and use incorrect syntax in html, the browser will do its best to recover. In xhtml, it would just completely fail. Which approach is better is debatable.

XML can handle implicitly closed tags, they call them "empty" in the spec here:

https://www.w3.org/TR/xml/#sec-starttags

Empty tags in XML are not implicitly closed. They require the explicit /.
XML can handle <img /> but not <img> followed by tagsoup (like HTML handles).
One thing I can think of is tag names being upper case in HTML and lower case in XHTML in the DOM.
> HTML5 could have taken the extra step of defining a canonical XML or XML-compatible DOM encoding, or at least encouraged it.

Yeah and then we could have called it xhtml5. Too bad that does not exist. Oh wait https://html.spec.whatwg.org/multipage/xhtml.html

> But the anti-XML sentiment was explicit and spiteful.

No, xhtml was just a bad idea creating tons of problems and solving none.

> xhtml was just a bad idea creating tons of problems and solving none.

Well an XHTML parser (and serializer) is a lot simpler, which is a pretty meaningful problem to solve.

What problems does xhtml create?

> Well an XHTML parser (and serializer) is a lot simpler

Perhaps, but a combined html and xhtml parser is more complex than just a html parser. Since html already is entrenched, xhtml would be in addition to html, not instead of.

XML/XHTML is a fairly strict language syntax wise compared to HTML, tags are either explicitly self-closing i.e. <img/> or terminated with a matching closing-tag, no exceptions.

HTML has special rules depending on the tag's type, ie a bunch of them are just written (<img>) and the parser doesn't even really want to see a matching closing tag, or tags like <script> that has a special mode that stops being a HTML parser up until </script> is found. (1)

A HTML parser can become a XML parser by disabling a bunch of special-features and supporting self-closing tags (depending on XML level).

A XML parser needs a ton of "hacks" to become a HTML parser.

Also browsers needs an XML parser anyhow to support svg that's an xml-based format, also the DOM spec is written to support namespaces's like XML.

XSLT did complicate things, and most importantly it seems many relied on that one old implementation written in the 90s that was a swiss-cheese when it came to security concerns that nobody wanted to spend money on maintaining.

(1): https://html.spec.whatwg.org/multipage/parsing.html#script-d...

> A HTML parser can become a XML parser by disabling a bunch of special-features

Even if this was true it would still increase complexity to have two parsing modes compared to just a html parser.

All the problems of XML, such as the billion laughs attack, and reading local files as DTDs. It should have been XML-compatible strict parsing without pulling in all of XML's complexity that only hackers ever use.
The main one is that even a slightly broken XHTML document will fail to render. HTML is much more forgiving.
With the benefit of hindsight, if the web had been that way from the beginning, I think we would have been better off. The moment you tested your content in any browser, you'd immediately see if it was broken.

But it wasn't something that could get introduced later, after all the broken content that already existed.

With all respect - the opposite is true. The web succeeded because HTML and HTTP are easy standards easily writable by humans with text editors. HTML was writable by non-programmers.
Yeah, I think SGML HTML as the first pass was a mistake. All my early websites were XHTML until people called them "bad"...
That's what browsers at the time did. But the format could be used with a lenient parser if anyone wanted that
The HTML spec actually includes how to parse broken HTML. https://html.spec.whatwg.org/multipage/parsing.html#parse-er...
> But the format could be used with a lenient parser if anyone wanted that

Congratulation on reinventing HTML.

i think xhtml happened before the wider world of web devs were ready for it. Component based architectures took longer to be adopted than I certainly expected.

It might actually work if reintroduced these days as long as we can consider many components to be valid documents.

There is nothing component-based about xhtml compared to html. It is just html with xml syntax.
It was reintroduced, in the form of jsx.

Sure there is some embedded JS in there as well but ignore that and JSX is thr XHTML comeback story.

And jsx was kind of weird because e4x existed (and was never widespread, and implementations of it went away).

I suppose the important part was that jsx needed to be compiled, which means it couldn't introduce any new security issues…

The XSLT 1.0 spec specifically was written pretty badly, though, to my recollection; I had a hard time at making sense of it
Yeah, XSLT 1.0 has some really obvious missteps, so much so that to my knowledge basically nobody just implements XSLT 1.0. What they actually support is (most of) XSLT 1.0 plus a handful of EXSLT extensions (which are completely unofficial and not part of any XSLT spec, by the way). In my opinion the EXSLT stuff is the bare minimum needed to make XSLT 1.0 at least a passable language. Meanwhile, the XSLT spec evolved into 2.0 and 3.0, which as far as I'm aware, even to this day, has no complete open-source implementation.
> XHTML was dropped in favor of HTML5 and XSLT was pretty much useless after that

Client-side XSLT was always pretty useless, but I dont see what HTML5 has to do with it?

The only real use case for client-side XSLT was for styling/layout back before CSS became widely supported. Improvements in CSS support made XSLT unnecessary.

And the rendering was very slow back at the day.