I have some older xsl transformations that I will modify soon. They generated XHTML code from a home-grown XML format. Since I am touching these XSL files anyway, I am wondering how I will deal with HTML 5 not being XML anymore.
I guess it won't be terrible if I still generate HTML (the browsers will still display it), but is there maybe something that is a better solution? Is there an "XHTML 5" corresponding to HTML 5?
-
1Have you read the chapter The XML syntax in the HTML5 specification? See also The XML serialization of HTML5, aka ‘XHTML5’ by Mathias Bynens.Tsundoku– Tsundoku2018年10月28日 18:55:20 +00:00Commented Oct 28, 2018 at 18:55
2 Answers 2
I am wondering how I will deal with HTML 5 not being XML anymore.
HTML5, unlike its predecessors, is defined as an abstract document, with three different concrete representations (note, however, that it is not guaranteed that every representation can express every possible abstract document):
- DOM5, an in-memory object format with a defined API
- HTML5, a textual serialization, inspired by how browsers actually parsed HTML4 (as opposed to the specification, according to which HTML4 was defined as an application of SGML, which no browser except Avaya and Emacs/w3 ever correctly was able to parse)
- XHTML5, an application of XML intended as the continuation of XHTML 1.1 (not XHTML2)
The latter one is of course the one that is relevant to you.
Note that there is a common subset that makes a document both valid HTML5 and XHTML5, minus the difference in headers. In particular, the HTML5 serialization explicitly allows (and ignores) an xmlns
attribute and certain others, precisely for this purpose.
If you can move forward to XSLT 3.0, then you can simply say <xsl:output method="html" version="5"/>
to generate HTML5.