W3C validators, Ajax & SOAP: a different way to test markup and CSS validity

This experiment is the work of its author and has no endorsement whatsoever. It is for now is far from being bullet-proof. This document captures the work done and the lessons learned.


People use the Valid HTML logo to show that their page is valid, whether it really is or not. Wanting to play with Ajax and use the SOAP interface of the mark-up validator, I wanted to try to make this logo more dynamic: allow one to check, on the page, whether it is valid or not.

I wanted to call to the SOAP call directly from the page, which turned out to be impossible, as for security reasons XMLHttpRequest() only works on the same domain as the document, and I need to do a SOAP call on the W3C validator server.

So I found the following trick while looking around: use an inline frame from the W3C validator server. And because I need to pass the URL of the document to validate, I ended up needing some extra JavaScript.

How to use it

Edit your document as follows:

  1. Choose an unused id, e.g. my-validator.

  2. There are two options here:

  3. Add the following somewhere in the body:

    <div id='my-validator' />

This shows an inline frame as follows:

Clicking on Check? will tell you if this page is both HTML and CSS valid or not.

This is more complex than the simple single JavaScript call I had originally envisioned, and in the end since I ended up using an inline frame, it's something that could have been done in other ways such as by using a CGI script instead of a document using Ajax, but this was an Ajax experiment so I decided to go all the way with it.


Source code

The source code is available on dev.w3.org. To get it from CVS:

bash$ export CVSROOT=":pserver:anonymous@dev.w3.org:/sources/public"
bash$ cvs login
(Logging in to anonymous@dev.w3.org)
CVS password: anonymous
bash$ cvs get 2006/aval

Ideas to continue this work

Thanks to Olivier Théreaux for his feedback and Philippe Le Hégaret for his help with DOMParser.

Hugo Haas
$Id: Overview.html,v 1.24 2006/02/22 10:16:00 hugo Exp $