Menu

#1830 XML - html5 DOCTYPE

None
pending-fixed
None
5
2016-02-12
2015-12-22
will69
No

Every HTML5 document contains the following dtd-less DOCTYPE declaration (see attachment):

This makes the XML parser spit out a lot of errors about undeclared elements. The XML spec says that a document with a dtd-less DOCTYPE declaration can still be well-formed. Since this is a very common case, it should be handled more gracefully. If there is no (internal or external) DTD, it would be more useful to stop validating and only report errors in well-formedness, so these do not get lost.

See also http://www.w3.org/TR/html51/syntax.html#the-doctype
and http://www.w3.org/TR/REC-xml/#NT-doctypedecl

1 Attachments

Discussion

  • will69

    will69 - 2015-12-22
    <!DOCTYPE html>
    
     
  • Eric Le Lay

    Eric Le Lay - 2016-01-31

    Long story short: it doesn't seem possible to disable dtd validation on the fly without seriously hacking Xerces-J. So I have to interrupt parsing and reparse when detecting the empty html doctype.

    Also the next thing you'll want is the charset:

    <meta charset="UTF-8">
    

    and that's not well-formed xml.

    So why not stick with the html sidekick?

     
  • will69

    will69 - 2016-02-09

    Hi Eric. Thanks for following up on this! There is an HTML and an XHTML syntax for HTML5. The XHTML variant is, of course, an application of xml. UTF-8/UTF-16 is the default encoding for any xml application. See here for a comparison of HTML5 and XHTML5. So is this actually a problem with Xerces and should be filed upstream? What about reading the first 15 characters and switching validation off, before invoking the parser? jEdit reads the first line of a file to determine the file type anyway, doesn't it?

    We are using jEdit in an educational context and XHTML/XHTML5 will probably always be the most common application of xml.

     
  • will69

    will69 - 2016-02-10

    This works great! It even starts validating again as soon as I use an internal subset.
    This is really helpful! Thanks a lot, Eric!

     
  • Eric Le Lay

    Eric Le Lay - 2016-02-10

    Good to know that it works for you.

    If you want to use the internal subset for entities but not validation, you can tell jEdit to turn off DTD validation by inserting

    on top of the document.

     

    Last edit: Eric Le Lay 2016-02-10
  • Eric Le Lay

    Eric Le Lay - 2016-02-12
    • status: open --> pending-fixed
    • Group: -->
     
  • Eric Le Lay

    Eric Le Lay - 2016-02-12

    will be in next release

     

Log in to post a comment.