Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to fix doctype rendered by CGI::Pretty.pm

Status
Not open for further replies.

sunw

Technical User
Sep 24, 2007
32
US
I have a web page created by CGI::pretty that only works with IE6, but not with IE7, nor with Firefox. I asked for help at HTML/CSS forum (for details, please refer to here). And I was told that the doctype of my web page is WRONG.

Here is the DOCTYPE:

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] lang="en-US" xml:lang="en-US">
<head><title>My Title</title><link rel="stylesheet" type="text/css" href="./mystyle.css" /></head>

The above code is generated by following perl code:

Code:
use CGI::Pretty qw( :html3 );
my $q = new CGI::Pretty;
my $html = $q->start_html(-title=>'My Title', -style=>{src=>'./mystyle.css'});
print $html;

And I was told that the xml declaration is not needed.

So, is there a way to get rid of the unnecessary XML declaration?

Thank you for your help!
 
BTW, I also tried to use CGI.pm, which renders the same doctype.
 
When I use your code, this is what gets printed:

Code:
<!DOCTYPE html
	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	 "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] lang="en-US" xml:lang="en-US">
<head>
<title>My Title</title>
<link rel="stylesheet" type="text/css" href="./mystyle.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>

I don't know why you are getting the extra <?xml> declaration at the top. By default it should not be printed. Find out what version of CGI.pm and CGI::pretty you are running, if they are older versions that might explain it.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Kevin,

My CGI.pm is 3.29, which is the latest and CGI::pretty is included in it, right? That's what I got from cpan site:


In addition, I just noticed that in order to make my page works with IE7, the doctype has to be:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">.

Any other doctypes would not work with IE7. How strange it is!
 
Well IE7 is a piece of shi(t)

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top