Re: HTML5 documents give critical error: Document not HTML

On 06/04/2010 03:25 PM, David Smith wrote:
> Many thanks Francois, I'll follow the bug you created.
>
>  > The problem seems to occur when the document cannot be parsed directly
>  > as XML and needs to be parsed as HTML (in your case, parsing as HTML is
>  > required because you use the entity "×", which is entirely
>  > correct, but since the XML parser doesn't know anything about HTML and
>  > since there's no more reference to a real DTD in HTML5, it doesn't know
>  > how to parse it)
>  >
>  > I've created bug 9850 to track this:
>  > http://www.w3.org/Bugs/Public/show_bug.cgi?id=9850
>
> A bit off topic but... what is the easiest way to allow all HTML
> Character Entity References in XML (to validate)?

It depends on what you mean by "validate" here...

The HTML entities are implicitly included in HTML5 AFAIK, so you're all 
set for validating your page against XHTML5 (the XML serialization of 
HTML5).

Validation in pure XML means your document refers to a document type and 
respects its constraints. That means you must change your DOCTYPE 
declaration to target an hypothetical custom HTML5 DTD, not defined by 
the HTML5 spec.

If you only mean to include the entities reference so that your XML 
document is "well-formed" for XML parsers, you still need to add the 
entities in a DOCTYPE declaration, with a DOCTYPE declaration like:

<!DOCTYPE html [

<!ENTITY % HTMLlat1 PUBLIC
    "-//W3C//ENTITIES Latin 1 for XHTML//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
%HTMLlat1;

<!ENTITY % HTMLsymbol PUBLIC
    "-//W3C//ENTITIES Symbols for XHTML//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent">
%HTMLsymbol;

<!ENTITY % HTMLspecial PUBLIC
    "-//W3C//ENTITIES Special for XHTML//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent">
%HTMLspecial;
]>

But then you've defined a document type and your document does not 
"validate" anymore against that document type. I don't think there's any 
way to define an entity outside of a DOCTYPE declaration.

Note I haven't checked the above declaration, which may be invalid.

In short, no easy way I can think of ;)

Francois.


>
>  > > Disclaimer (excuses, excuses): Please forgive the linked page above and
>  > > site in general, it rarely gets much TLC. Also, has anyone else cringed
>  > > or worse when re-reading a post they'd written some time before :|
>  >
>  > That's exactly how I feel when I have to take a look at code written
>  > some time before because of a bug like the one above ;)
>
> phew! not the only one then :)
>
> all the best
> Dave
>
> ------------------------------------------------------------------------
> Get a free e-mail account with Hotmail. Sign-up now.
> <http://clk.atdmt.com/UKM/go/197222280/direct/01/>

Received on Tuesday, 8 June 2010 09:06:06 UTC