Solving W3C 3in1 Validation Problem

I awoke this morning with an idea about solving the 3in1 W3C validation problem, and it worked! I’ve restored the validation links on my 3in1 page, so there’s one less problem page on my site.

It occurred to me that 3in1’s output shouldn’t be parsed as standard html, so a ‘’ exclusion is needed. After enclosing the 3in1 ‘echo’ statements in the cdata statement I was left with only 2 validation exceptions, both declarations without types. Here is what the main-copy code in my template looks like:

<div id="main-copy" style="width:870px; border:inset">
  
    <div style="width:<?php echo $mainwidth ?>px;font: 72% Tahoma;">
<![CDATA[
    <?php
    # Header with name & update-times (optional)
    echo $wxallupdated;
    echo '<h2>'.get_lang("WXSIM Forecast for:").' '.$wxallcity.'</h2>';
    
    # Theese can be used stand alone or together

    echo $wxalltop;     # "Top-forecast"
    echo $wxallgraph;   # Graph
    echo $wxallmain;    # Tabs
    ?>
]]>
    </div>
	<?php
    echo $wxallfooter;
    ?>
</div><!-- end main-copy -->

The untyped script declarations occurred in wxall.lastret.php’s $wxallhead and $wxallfooter declarations. This is the revised code:

$wxallhead = '
<script type="text/javascript">
// COMMERCIAL USE OF THIS FORECAST-SCRIPT STRICTLY FORBIDDEN.
var docready=[],$=function(){return{ready:function(fn){docready.push(fn)}}};
</script>
<link rel="stylesheet" type="text/css" media="screen" href="'.$wxallmainfolder.'css/wxall.css?'.$cssage.'" />
';
if($useustemp==1){$wxallhead.= '<link rel="stylesheet" type="text/css" media="screen" href="'.$wxallmainfolder.'css/US/wxall.css" />';}
$wxallfooter = '
<script type="text/javascript" src="'.$wxallmainfolder.'js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="'.$wxallmainfolder.'js/jquery-ui-1.9.1.min.js"></script>
<script type="text/javascript">$=jQuery;jQuery(document).ready(function(){for(n in docready){docready[n]()}});</script>
<script type="text/javascript" src="'.$wxallmainfolder.'js/highcharts.js"></script>
<script type="text/javascript" src="'.$wxallmainfolder.'js/wxsim.js"></script>
';

Validation is now successful! :smiley:

Jerry,
Thanks for sharing. More incremental knowledge for me to file away.

I don’t have those validation-problems here and it validates OK. Note tought, its HTML5.

// Henkka

I’m curious as to the validator you are using. For me even sivu2.php fails at validator.w3c.org with one error and 10 warnings.

This one: http://html5.validator.nu
Have never got the W3-validator to work for HTML5 yet…

Sääennuste [DWD,ECMWF,MET Norway] validates in that except for a few small things what not depend on 3in1 (mainly my dynamic sidemenu).

// Henkka

Hi Gerry,
i’ve changed my wxsim page with your code to fix w3c validations but it remains the code like the image below:

What’s wrong?
I’ve attached my .php file.
Thanks in advance,

Alessandro


wxsimallinone.php.txt (6.42 KB)

Comment out the CDATA closure like this:

When I discovered the problem and the solution, I forgot to modify my post above. Sorry about that. #-o

Fixed!
Thanks you so much for your fast reply.
Regards,

Alessandro