HTML::Lint vs. XML

  • Thread starter Jesse Sheidlower
  • Start date
J

Jesse Sheidlower

I've just started doing some real testing on my scripts,
and I've run into a problem already. I am trying to test
a generated Web page using WWW::Mechanize and Test::HTML::Lint,
following some posted suggestions from Andy Lester. But I'm
getting an error that doesn't seem to be described in the
Lint docs.

I generate my page using standard CGI.pm functions (via
Template Toolkit), starting with CGI::header and
CGI::start_html, which generates text beginning:

---
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>...
---

I then point at this the following test script:

---
#!/usr/bin/perl -w
use Test::More qw(no_plan);
use Test::HTML::Lint;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new();
isa_ok( $mech, "WWW::Mechanize" ) or die;
$mech->get( "http://127.0.0.1/cgi-bin/test/search.cgi" );
is ($mech->status, 200, "Fetched OK" );
html_ok( $mech->content, "Login page HTML" );
---

which produces the following test results:

---
ok 1 - The object isa WWW::Mechanize
ok 2 - Fetched OK
not ok 3 - Login page HTML
# Failed test (02libloading.t at line 10)
# Errors: Login page HTML
# (7:1) Unknown attribute "xmlns" for tag <html>
# (7:1) Unknown attribute "xml:lang" for tag <html>
1..3
# Looks like you failed 1 tests of 3.
---

What do I need to do to get Lint to accept this as valid HTML?

Thanks.

Jesse Sheidlower
 
A

Alan J. Flavell

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> [..]
What do I need to do to get Lint to accept this as valid HTML?

I can't answer the specific question, sorry, but you're surely aware
that it is _not_ "valid HTML"?

Appendix C of XHTML/1.0 describes a kludge whereby XHTML can be
force-fed to tag-soup slurpers on the pretext of it being HTML; but
it wouldn't fool a formal validator.[1]

Apologies if you already knew that and it was just a slip of
the keyboard. But the documentation for Lint doesn't seem to mention
XHTML, and the stuff it's complaining about, doesn't happen in HTML
/per se/.

Hope this is vaguely useful.


[1] and is rated by many to have been a distinctly bad idea. But
that's even more OT here.
 
J

James Willmore

On 7 Dec 2003 19:40:18 -0500
I've just started doing some real testing on my scripts,
and I've run into a problem already. I am trying to test
a generated Web page using WWW::Mechanize and Test::HTML::Lint,
following some posted suggestions from Andy Lester. But I'm
getting an error that doesn't seem to be described in the
Lint docs.

I generate my page using standard CGI.pm functions (via
Template Toolkit), starting with CGI::header and
CGI::start_html, which generates text beginning:

---
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"
xml:lang="en-US"><head>...

Deep in the reaches of the CGI documentation, there in mention of how
to make the output a particular version of HTML. I think it goes
something like ...

use CGI qw:)html4);

or something to that effect. This *may* let Lint verify the HTML in a
version it understands.

Check the documentation to verify. Salt to taste :)

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Barometer, n.: An ingenious instrument which indicates what kind
of weather we are having. -- Ambrose Bierce, "The Devil's
<Dictionary"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top