It has long been my understanding that one advantage of the XML syntax for writing HTML documents is that it also permits to include in HTML documents elements with a namespace that is not one of those specified by the HTML standard. For example, user-created elements in a user-created namespace describing books. But, reading the WhatWG specs, this seems to be forbidden, or I do not find how to do it (I mean, in a way that is conforming to the specs).
I am thinking about something similar to the following document.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
…
</head>
<body>
<h1>Title</h1>
<book xmlns="http://example.com/my-book-namespace">
…
</book>
</body>
</html>
I realize that of course the browser would not know how to render such elements coming from unknown namespaces, but this may not be a problem (I expect browsers would simply ignore such elements). For example, some javascript on the page could use such elements as data in order to generate HTML elements dynamically.
For example, this tutorial about Java Server Faces includes elements in the JSF namespace in what seems to be intended as a conforming XHTML page.
But the specs seems to imply that such an example would be non conforming, and even, that there may be no way of including such elements in an HTML document. “The exact allowed contents of each individual element depend on the content model of that element, as described earlier in this specification. Elements must not contain content that their content model disallows.” (elements); and the body element specifies only Flow content as Content model; which does not seem to permit using elements outside of those explicitly specified by the HTML specification.
So, if I insist in producing only spec-conforming HTML documents, should I refrain from including in an HTML document elements from a namespace different from the HTML, SVG and MathML namespaces?