LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-03-2017, 04:05 PM   #1
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,330
Blog Entries: 4

Rep: Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843
Question RelaxNG (Relax NG) is expecting a namespace and I don't know why


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.

Last edited by sundialsvcs; 08-03-2017 at 04:37 PM.
 
Old 08-03-2017, 08:40 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 649

Rep: Reputation: 249Reputation: 249Reputation: 249
Strange! I get the same error with loadHTML() but it validates if your html is loaded from a file:
PHP Code:
$ cat heredoc.html 
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head><title>dummy</title></head>
<body>
$html
</body>
</html>

$ cat script.php
<?php
$file 
'heredoc.html';
$schema '/usr/share/xml/xhtml-relaxng/xhtml.rng';
$doc = new DOMDocument;
$doc->load($file);
if (
$doc->RelaxNGValidate($schema)) {
    print 
"Valid.\n";
} else {
    print 
"Invalid.\n";
}
?>
 
Old 08-04-2017, 09:29 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,330
Blog Entries: 4

Original Poster
Rep: Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843Reputation: 2843
I haven't yet tried to reproduce this behavior.

I'm switching to making an external call to the w3c.org validation net-service. I've got to get this damned ticket closed, somehow.
 
  


Reply

Tags
html, html5, relax, relaxng, validation


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Everyone can relax, kuyalfinator has returned! kuyalfinator LinuxQuestions.org Member Intro 0 03-02-2011 06:23 AM
Everybody relax. I'm here. Morik the Rogue LinuxQuestions.org Member Intro 2 08-23-2009 01:32 AM
How do you relax when you use Linux? jaakkop General 39 03-24-2005 09:25 PM
I think it is time when we put our struggle with linux aside and try to relax neo77777 General 1 04-08-2003 12:41 AM
Relax folks..give him a break :-p andyW LQ Suggestions & Feedback 0 12-03-2001 04:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration