Valid XHTML + RDFa
As I said before, RDFa is a technology I'm interested in, because I think it will become of great importance in the semantic web. Hopefully, I'll soon have an opportunity to do a small contribution, so I'm very excited. Readers of this blog know that my web page has bits of embedded RDFa. When I made that announcement, W3C's validator didn't have support for XHTML+RDFa. Fortunately, now it does have support.
Today I checked my web with the validator and I discovered it was failing the tests. Shame on me. I made a few changes to quickly fix the problem:
- The DOCTYPE in the XHTML header was wrong. There is an specific DOCTYPE for XHTML+RDFa.
- I was serving the wrong Content-Type. Well, actually it was a problem with my CMS (textpattern). I found a patch to server 'application/xhtml+xml' with TextPattern.
- After applying the above patch, my CMS correctly served 'application/xhtml+xml'... if it was asked to in the Accept header. That's O.K. but, what happens when the client doesn't send an Accept header? The W3C validator doesn't, so my web was still failing the tests. I rewrote the patch as follows to serve 'application/xhtml+xml' as the default (instead of 'text/html'):
if ( stristr($_SERVER["HTTP_ACCEPT"],"text/html") && !stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) { header("content-type: text/html; charset=utf-8"); } else { header("content-type: application/xhtml+xml; charset=utf-8"); }
Valid XHTML+RDFa at last!