Validating DHTML against a schema

Discussion in 'HTML' started by Jim Higson, Dec 19, 2005.

  1. Jim Higson

    Jim Higson Guest

    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
     
    Jim Higson, Dec 19, 2005
    #1
    1. Advertising

  2. Jim Higson

    Guest

    Jim Higson wrote:
    > 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?

    --
    Hywel
     
    , Dec 19, 2005
    #2
    1. Advertising

  3. Jim Higson

    Jim Higson Guest

    wrote:

    >
    > Jim Higson wrote:
    >> 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?


    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.


    --
    Jim
     
    Jim Higson, Dec 19, 2005
    #3
  4. Jim Higson

    Andy Dingley Guest

    On Mon, 19 Dec 2005 11:56:23 +0000, Jim Higson <> wrote:

    >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)
     
    Andy Dingley, Dec 19, 2005
    #4
  5. Jim Higson

    Toby Inkster Guest

    Jim Higson wrote:

    > 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?

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Dec 19, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. simon ames
    Replies:
    1
    Views:
    505
    Joerg Jooss
    Apr 11, 2004
  2. Mike P
    Replies:
    1
    Views:
    356
    Mike P
    Dec 6, 2004
  3. Ben Jessel
    Replies:
    0
    Views:
    405
    Ben Jessel
    Aug 5, 2004
  4. srujana
    Replies:
    2
    Views:
    2,434
    Soren Kuula
    Dec 31, 2005
  5. First_step_to_xml
    Replies:
    0
    Views:
    705
    First_step_to_xml
    Jun 28, 2006
Loading...

Share This Page