On 12/18/21 13:01, Patrice Dumas wrote:
It seems that it does not change the work required compared to XHTML 1.1
which is to have a correct XML document. Something I cannot find,
however, is what to put at the beginning to be able to check validity
of the resulting document if it is HTML5 XML. Can you please tell me?
As far as I can tell, you don't need to put anything at the start:
https://html.spec.whatwg.org/multipage/xhtml.html#the-xhtml-syntax
A validator should allow you to specify what you want to validate against.
This should be OK:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
For "polyglot" output, leave off the <?xml?> declaration.
It seems to me that XML_OUTPUT_MODE "polyglot" would only need changing
some customization variable for the header, so I am not so convinced
that it is really interesting.
A major difference between XML and HTML is the handling of empty elements.
The following are valid HTML:
<a name="foo">
<a name="foo"></a>
<hr>
The following are valid XML:
<a name="foo"/>
<a name="foo"></a>
<hr></hr>
<hr/>
Note that the following are *invalid* HTML:
<hr></hr>
<a name="foo"> -- error if not followed by a closing </a> tag
while this is invalid XML:
<hr>
<a name="foo">
The following ("polyglot") output is suggested is they are valid both as HTML
and XML:
<hr/>
<a name="foo"></a>
You have to know which elements have empty content (hr) and which don't (a).
--
--Per Bothner
[email protected] http://per.bothner.com/