GNOME Bugzilla – Bug 679539
Fails to validate documents with a DOCTYPE but without a DTD
Last modified: 2017-06-14 00:33:46 UTC
XML 1.0 points out that: "Note that it is possible to construct a well-formed document containing a doctypedecl that neither points to an external subset nor contains an internal subset." http://www.w3.org/TR/REC-xml/#sec-prolog-dtd Thus, when running xmllint --validate http://example.com/XHTML-5-document.xhtml then xmlint should whine if the DOCTYPE says: <!DOCTYPE HTML> or <!DOCTYPE hTmL> See: http://www.w3.org/TR/REC-xml/#vc-roottype However, xmllint fails to report validity errors with the DOCTYPE. Instead, it reports errors that the document is lacking a DTD. Please make sure that xmllint --validate will also check that root "fragmetn" of the DOCTYPE uses the correct casing and/or that it matches the root elemetn. (If the namespace is known, as it is for XHML, then xmllint would know that root element should be in lowercase. Thus, in that case it might make sense say that it is the DOCTYPE that is in error. In other cases, if there is no namespace, then it might be better to say that it is the root element that is in error.
Yes, libxml2 could verify the name of the root element even if there's no DTD, but I don't understand how this would be useful. The spec defines validity as: "Definition: An XML document is *valid* if it has an associated document type declaration and if the document complies with the constraints expressed in it." Documents without an associated DTD aren't valid by definition.