W3C home > Mailing lists > Public > www-validator@w3.org > June 2003

Re: W3 Validator XHTML parse error with CGI.pm generated $query->start_html(-script)

From: Brock Murch <bmurch@seas.marine.usf.edu>
Date: Wed, 18 Jun 2003 15:32:32 -0400
To: Lincoln Stein <lstein@cshl.edu>, www-validator@w3.org
Message-Id: <200306181532.32121.bmurch@marine.usf.edu>

Lincoln:
	Sorry for the delay... works great too! Will this be included in newer 
versions of CGI.pm? Just curious in case of upgrades.

Thanks
Brock Murch



On Monday 16 June 2003 4:59 pm, Lincoln Stein wrote:
> Try this.
>
>    my ($cdata_start,$cdata_end);
>     if ($XHTML) {
>        $cdata_start    = "$comment<![CDATA[\n";
>        $cdata_end     .= "\n$comment]]>";
>     } else {
>        $cdata_start  =  "\n<!-- Hide script\n";
>        $cdata_end    = $comment;
>        $cdata_end   .= " End script hiding -->\n";
>    }
>      my(@satts);
>
> Best, L
>
> On Monday 16 June 2003 01:51 pm, Brock Murch wrote:
> > Dear Lincoln :
> > 	You probably saw the email from the w3-validator regarding the issue:
> >
> > "The validator is correct - you are not allowed to put "--" inside an XML
> > comment. (Even in (SGML) HTML it would be wrong in this case.) In XHTML
> > the content of the script element is #PCDATA, not CDATA (since XML
> > doesn't have the latter), so all markup is treated normally. In
> > particular, you do indeed want a CDATA section so that you don't need to
> > escape markup characters all over the place; but you do not want to put
> > the script inside <!-- -->, because in XHTML's script element that really
> > is a comment. You may wish to consider using <script src="..." />
> > instead."
> >
> > So, that being the case, that the XHTML's script element is really a
> > comment, and if I am scripting for XHTML ( thus assuming that the browser
> > is capable of parsing according to the DOCTYPE ), perhaps this code
> > snippet would work OK for CGI.pm
> >
> > ###########################################
> > #    Original Coding
> > ###########################################
> > #    my $cdata_start  =  "\n<!-- Hide script\n";
> > #    $cdata_start    .= "$comment<![CDATA[\n"  if $XHTML;
> > #    my $cdata_end    = $XHTML ? "\n$comment]]>" : $comment;
> > #    $cdata_end      .= " End script hiding -->\n";
> > ###########################################
> > #insert for XHTML validation Testing
> > ###########################################
> >     my $cdata_start  =  "\n<!-- Hide script\n" unless $XHTML;
> >     $cdata_start    .= "$comment<![CDATA[\n"  if $XHTML;
> >     my $cdata_end    = $XHTML ? "\n$comment]]>" : $comment;
> >     $cdata_end      .= " End script hiding -->\n" unless $XHTML;
> >
> > This seems to work just fine and will not affect the backwards
> > compatibility issue unless the programmer is specifically coding for
> > XHTML..... I believe that if the XHTML DOCTYPE is specified, the the
> > XHTML rules really should be in place. I really can't follow the w3
> > suggestion: ' You may wish to consider using <script src="..." />
> > instead."' Since my perl script generates all the javascript on the fly,
> > and creating and cleaning up files is a tremendous drag.
> >
> > This seems to work for me anyways, perhaps you might consider
> > incorporating it?
> >
> >
> > Brock Murch
> >
> > On Sunday 15 June 2003 5:34 pm, Lincoln Stein wrote:
> > > Sadly, removing the comments will break the display on older browsers,
> > > so I can't do that.
> > >
> > > Lincoln
> > >
> > > On Friday 13 June 2003 01:44 pm, Brock Murch wrote:
> > > > Mr. Stein & Validator List:
> > > >
> > > > Background:
> > > > perl -MCGI -e 'print $CGI::VERSION' > 2.95
> > > > perl -v >This is perl, v5.8.0 built for i386-linux-thread-multi
> > > > server:Apache/2.0.40 (Red Hat Linux) mod_perl/1.99_05-dev Perl/v5.8.0
> > > > mod_auth_pgsql/0.9.12 PHP/4.2.2 mod_python/3.0.0 Python/2.2.1
> > > > mod_ssl/2.0.40 OpenSSL/0.9.6b DAV/2
> > > > cat /etc/redhat-release
> > > > Red Hat Linux release 8.0 (Psyche)
> > > >
> > > > When trying to validate xhtml I am having an error:
> > > >
> > > > This is the code snippet:
> > > >
> > > > print $query->header(-target=>'_blank');
> > > > print $query->start_html(	-title=>"$title",
> > > > 				-script=>"$javascript",
> > > > 				-onLoad=>"launch()",
> > > > 				-head=>[ Link({-rel=>'stylesheet',
> > > > 					 -type=>'text/css',
> > > > 			                 -href=>'/css/SSTProject.css'}),
> > > > 			           Link({-rel=>'stylesheet',
> > > > 					 -type=>'text/css',
> > > > 				         -href=>'/css/common.css'})]
> > > > 				);
> > > >
> > > > Basically the XML validator chokes on comments inside the <script>
> > > > tag with xhtml. If there is a open <!-- to hide the script... (placed
> > > > there via the CGI.pm module) and later a decrement is used (ie var
> > > > this-- ) the parser calls it a  "invalid comment declaration" I have
> > > > saved a copy of the script output as a static page here:
> > > >
> > > > http://www.imars.usf.edu/SST/animate_CGI.html
> > > > http://validator.w3.org/check?uri=http%3A%2F%2Fwww.imars.usf.edu%2FSS
> > > >T% 2F an imate_CGI.html
> > > >
> > > > To make the page pass the parse test I only need to do remove the
> > > > <!--comments tags-->:
> > > >
> > > > eg:
> > > > diff animate.html animate_CGI.html
> > > > 9c9
> > > > <
> > > > ---
> > > >
> > > > > <!-- Hide script
> > > >
> > > > 298c298
> > > > < //]]>
> > > > ---
> > > >
> > > > > //]]> End script hiding -->
> > > >
> > > > The page is then validated
> > > >
> > > > http://www.imars.usf.edu/SST/animate.html
> > > > http://validator.w3.org/check?uri=http%3A%2F%2Fwww.imars.usf.edu%2FSS
> > > >T% 2F an imate.html
> > > >
> > > > Any ideas on this? I am not a member of the list so please mail me
> > > > directly.
Received on Wednesday, 18 June 2003 15:40:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:09 GMT