I've been looking around for answers for a while but I think it's time to put this to the experts. I'm about spent and need some direction!

I have been trying to create XHTML 1.1 Strict using cgi.pm, and trying to bend it to make it work. I'm starting to question whether I'm heading in the right direction though. For example, to get a header that validates, I have to hack the output (the sub is listed at the end of this post).

The manual says to generate meta http-equiv tags this way, but the output is:

<meta http-equiv="content-language" content="en-gb">

But to validate, we need:

<meta http-equiv="content-language" content="en-gb" />

Also, the script produces a language attribute which is invalid:

<script language="JavaScript" src="/sort.js" type="text/javascript"></script>

I also removed the <?xml... > line to prevent windows quirk mode. There are also other problems such as:

scrolling_list(-name=>'source',-values=>{%list}, -size=>5, -multiple=>'true')

which produces:

<select name="source" size="5" multiple>

but we need:

<select name="source" size="5" multiple="multiple">

to validate. The same is true for selected and checked.

As you can see below, I got around this using s//. But surely there must be a better way?

Is it still the case that the CGI module is not xhtml standards complient or it's still buggy? Are there any better solutions?

Here's my sub:

sub getheader { my $query = new CGI; my $hdr = $query->header(); $_ = $query->start_html( -title=>$_[0], -meta=>{ 'description'=>'Test', 'keywords'=>'test', 'rating'=>'general', 'robots'=>'all' }, -head=>[ meta({ -http_equiv=>'content-language', -content=>'en-gb@' }), meta({ -http_equiv=>'content-type', -content=>'text/html; charset=iso-8859-1@' })], -style=>{ -src=>'/atlantia.css', -media=>'screen', -charset=>'utf-8' }, -dtd=>'-//W3C//DTD XHTML 1.1 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd', -script=>{ -src=>'/sort.js' }, -onLoad=> defined($_[1]) ? "document.$_[1].focus()" : '', ); #----remove xml prologue <?xml version...> from before doctype to prevent windows 'quirk mode' s/\n//; $_ = $'; #----remove invalid language tag s/language=\"JavaScript\"//; #----replace invalid tag end > with /> for meta http-equiv s/@\">\n/\" \/>\n/g; return $hdr.$_; }

I am running perl v5.6.1 under 5.2.1-RELEASE FreeBSD i386, with cgi version 2.752


In reply to CGI and XHTML by gnewcs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.