Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Validating DHTML against a schema
- Jim Higson
December 19, 2005, 11:56 am
rate this thread
I've used various HTML validators that grab the (X)HTML and run it against a
schema, but what about validating the 'live' HTML once the DOMs been
modified by a script?
Is there any (reasonably easy) way to tell a browser to send the current
state of a page to a validator?
Re: Validating DHTML against a schema
When modifying the page, modify the DOM (by adding elements to it)
rather than trying to modify the page source (with document.write() )
This will become increasingly important as we move towards XHTML being
processed as XML.
This doesn't guarantee that the page will be valid, but it does preserve
well-formedness at least, and that's most of the battle.
It would be an interesting exercise to write a FireFox extension that
validated the DOM's current contents, rather than the original source.
You already have most of the hooks in place to do this - FF makes it
quite easy to get the "rendered" source, which I think is tracking the
state of the page that you need (I've certainly manually cut and pasted
this into validators)