I am constructing an XHTML document like this (in PHP):
Code:
$html = <<<"HEREDOC"
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head><title>dummy</title></head>
<body>
$html
</body>
</html>
HEREDOC;
... and, as you can see, I think that I am properly specifying everything.
And "html5.validator.nu"; declared the resulting HTML to be valid. But RelaxNG
(DOMDocument::RelaxNGValidate) doesn't seem to think so:
Code:
Error 15: Expecting a namespace for element html on line 2
What am I missing here?
Since I am calling a method of PHP's
DOMDocument object, I of course looked for options in that object which might possibly be relevant, but found none so far. Various fiddlings with the DOCTYPE or HTML tags also have no effect.
- - -
Edit: Now I am
thoroughly flummoxed. I see the
same message ("always 'element html'"),
even when the first node is not <html> !!!
Let's say I remove the text up to the
<body> tag and, say, add four blank lines above it. When I run the script, the message will now say:
Code:
Error 15: Expecting a namespace for element html on line 5
(not element body!) ... it will, in other words, reflect the fact that the document begins on "line 5," but it will always refer to "
element html."
(This is PHP-7 latest ...)
The code is being validated against the
/usr/share/xml/xhtml-relaxng/xhtml.rng file that is installed by the
xhtml-relaxrng Ubuntu package.