Validating DHTML against a schema

J

Jim Higson

Debugging scrited sites would be easier if I could check my HTML stays
valid.

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?

Ta,
Jim
 
H

hywel.jenkins

Jim said:
Debugging scrited sites would be easier if I could check my HTML stays
valid.

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?

Why not just ensure that your script outputs schema-valid HTML in the
first place?
 
J

Jim Higson

Why not just ensure that your script outputs schema-valid HTML in the
first place?

Sure, but how do I check?

I mean, it *looks* valid, but there are DOM elements being changed here and
there and there's no way to be certain other than schema validation.
 
A

Andy Dingley

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?

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)
 
T

Toby Inkster

Jim said:
I mean, it *looks* valid, but there are DOM elements being changed here and
there and there's no way to be certain other than schema validation.

Perhaps grab document.body.innerHTML and send it to a validator?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top