KBD

Keith Devens .com

Friday, September 5, 2008 Flag waving
XML wasn't designed to be edited by humans on a regular basis. – Guido van Rossum

Archive: May 14, 2004

← May 12, 2004May 15, 2004 →

Daily link icon Friday, May 14, 2004

Web specifications have become too complex

I think web specifications have become too complex. I'm trying, really I am, to conform to XHTML 1.1 (why? just because). I've pretty much concluded that this is just all too complex and time-consuming for any but the most supremely anal-retentive people with nearly unlimited free time to be certain that their page conforms to all the relevant specifications. The W3C's validator doesn't even check if the Content-type returned by an XHTML 1.x page is 'application/xhtml+xml', which has a "SHOULD" level of necessity in the spec.

Besides content types, there are character encodings, which have to be specified in two or three places (and then the actual encoding of the page content has to be correct), and the language of a page, which can be specified in a few different ways, and I'm not yet certain which way is the correct one. Plus, it's actually fairly hard to edit pages by hand and be sure that they're valid XHTML 1.1.

What a mess.

Oh great, the (X)HTML validator is broken! Update: no it's not, Mozilla's view source is broken!

Oh great, the (X)HTML validator is broken. I use a variation of Mark Pilgrim's code to check if the user-agent supports 'application/xhtml+xml':

<?php
if(strpos($_SERVER['HTTP_ACCEPT'],'application/xhtml+xml') !== false)
    
header("Content-type: application/xhtml+xml");
else
    
header("Content-type: text/html");
?>

The validator must not be sending an 'application/xhtml+xml' Accept header, because my page is being returned as text/html. The validator then complains that I have no DOCTYPE declaration, even though I'm using one of the declarations included in their list. If I unconditionally return the page with an 'application/xhtml+xml' Content-type, the validator correctly validates the page. What's going on here?

Update: It turns out there's an error in Mozilla's "view source" feature! I couldn't figure out why my page wasn't validating. I tried validating Simon's page, which validated. I finally checked the "show source" feature of the validator, and it turned out I was getting the following PHP notice (reformatted slightly):

<br />
<b>Notice</b>: Undefined index: HTTP_ACCEPT
   in <b>[filename]</b> on line <b>2</b><br />

which Mozilla's "view source" didn't show! It just showed three blank lines at the top of the page. It turns out that the validator doesn't send any Accept header at all, so I changed the above code to (reformatted slightly):

<?php
if(isset($_SERVER['HTTP_ACCEPT']) and
    
strpos($_SERVER['HTTP_ACCEPT'],'application/xhtml+xml') !== false)
    
header("Content-type: application/xhtml+xml");
else
    
header("Content-type: text/html");
?>

And that made it work.


I've almost decided that viewing PHP's notices are more trouble than they're worth. Any code I release should be developed with as strict a level of error messages as possible, but there's no reason I should have to put up with it in my code if I don't want to. Though, it's not clear how to develop with strict errors on without all my pages having that level of error messages.

Update: Maybe rather than going straight to 'text/html' I should be going to something like 'text/xml' first.

HTTP caching and Etags

There's a lot more to conditional get and HTTP caching than If-None-Match and Etag headers.

← May 12, 2004May 15, 2004 →
September 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
282930 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

new⇒I hate ASP.NET

CF, why pick that piece of trash?​Cold Confusion. Is it finally​really a OO...

ColdConfusion: Sep 5, 8:36pm

new⇒Maps of Iraq

This is for Linda, I will be​visiting that site some time in the​near futur...

Bob: Sep 5, 1:20pm

Girls, please don't get breast implants

Well alright I just read my above​comment and I wanted to add​this...I shou...

76.66.140.8: Sep 4, 7:31pm

Spider solitaire

I don't think the question was​necessarily if there are unbeatable​games.  ...

Jared: Sep 4, 12:44pm

Convert Pantone Colors to RGB and Hex - Color Conversion Chart

The colors on those website don't​seem to relate to the pantone data​we hav...

blah: Sep 3, 10:12am

Generated in about 0.049s.

(Used 7 db queries)

mobile phone