Hacker News new | ask | show | jobs
by whizzter 45 days ago
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...

1 comments

> 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.

The idea would be to eventually deprecate "legacy" html, of course.

Whether that kind of backwards-incompatible breakage would ever become acceptable is a completely different story. But we ditched Flash, ActiveX, Silverlight, and Java applets, so who knows what could have been!

Who would want to use a browser which couldn’t render html? Even if a better format arrived, there are millions of already existing html pages which people would want to be able to read.