Looking for HTML validator

V

Vadim

Hi!

I am looking for HTML validator with the following restrictions:
1. Web server is the localhost (page should be validated locally).
2. The page is dynamic (generated by PHP with client side javascript,
which alters the DOM).

I tried the following:
1. Tidy Firefox extenstion (http://users.skynet.be/mgueury/mozilla/).
Unfortunately, it doesn't really makes the real DOM validation. In my
JS code, I had .inerHTML code injection, but this extension didn't show
the injected html code.
2. I am using FireBug Firefox extenstion. This extenstion shows the
real DOM, but unfortunately it doesn't validate the HTML.
3. MS developper toolbar for IE and Web Developper Firefox extenstion
make only external HTML validation.

Any advise?

Thanks a lot!

Vadim
 
D

David Dorward

Vadim said:
1. Web server is the localhost (page should be validated locally).
http://validator.w3.org/source/

2. The page is dynamic (generated by PHP with client side javascript,
which alters the DOM).
2. I am using FireBug Firefox extenstion. This extenstion shows the
real DOM, but unfortunately it doesn't validate the HTML.

Take the generated markup and paste it into the validator.
 
V

Vadim

Thanks for help, but it's a liitle difficult to make...
Are there any real-time DOM validators?
 
V

VK

Vadim said:
Are there any real-time DOM validators?

There is only one King :)

You can install Firefox add-on at
<https://addons.mozilla.org/firefox/249/> Please not that HTML Tidy is
called there "HTML Validator" but it is not in the sense of W3C
Validator. Some differences are presented (Tidy is more relaxed in
favor of the real world practice). Yet it is a rather nice markup
checker and pritty-printer. You can use it at the debug time and make
the final validation at validator.w3.org
 
D

David Dorward

You can install Firefox add-on at
<https://addons.mozilla.org/firefox/249/>

And that does what the author wants? Cool.

Hang on everyone! This is VK! I don't think I've ever responded to one of
his posts without my answer basically boiling down to "You're wrong!", but
I haven't fiddled with this extension before (it is based on tidy, and I
don't much care for tidy's attempts at syntax checking) so how about some
testing?

First I construct a test document...

http://dorward.me.uk/tmp/mod.html

A very simple HTML 4.01 Strict document with two buttons that call
JavaScript functions that modify the document - one uses DOM methods to add
an image that (a) lacks an alt attribute and (b) is being added somewhere
it isn't allowed, the other uses innerHTML to modify the document so the
body looks like:

<body>
</p><p>xxx</p></p>
</body>

Download and install the Tidy extension that VK referenced fire it up
and ...

Valid!

Excellent. It hasn't got any false positives from this documents then. Now
how about we try my scripts.

First the DOM script. Clicky, Clicky. Hmm. Still "valid".

Then the innerHTML script. Clicky, Clicky. Hmm. Still "valid".

So no. It doesn't work as VK claims ... hang on a minute.

Oh my. Why did I bother? I've just gone back and looked at the post that
started this thread. VADIM HAD ALREADY TRIED THAT EXTENSION AND DISMISSED
IT AS NOT DOING WHAT HE WANTED! ARGH!
Please not that HTML Tidy is
called there "HTML Validator" but it is not in the sense of W3C
Validator.

Actually, the current beta has a real SGML parser
Some differences are presented (Tidy is more relaxed in
favor of the real world practice).

No, it isn't. It has bugs, and as far as I'm aware they are recognised as
bugs and not fobbed off as "real world practise", I think you may be mixing
it up with that CSE thingy.
Yet it is a rather nice markup checker and pritty-printer. You can use it
at the debug time and make the final validation at validator.w3.org

Just so long as you remember to do a proper check and don't get lulled into
a false sense of security.
 
V

VK

David said:
And that does what the author wants? Cool.

OP wanted something to not run after each change to w3.org This is what
has being said in the post I read and answered.
Hang on everyone! This is VK! I don't think I've ever responded to one of
his posts without my answer basically boiling down to "You're wrong!", but
I haven't fiddled with this extension before (it is based on tidy, and I
don't much care for tidy's attempts at syntax checking) so how about some
testing?

First I construct a test document...

http://dorward.me.uk/tmp/mod.html

A very simple HTML 4.01 Strict document with two buttons that call
JavaScript functions that modify the document - one uses DOM methods to add
an image that (a) lacks an alt attribute and (b) is being added somewhere
it isn't allowed, the other uses innerHTML to modify the document so the
body looks like:

I'm missing the point of this exersice. Of course using DOM methods and
even document.write I can bring the runtime document structure in the
state far away from what was originally presented to any validator. So
what's the point? Validator of any kind (including the one at w3.org)
checks the document as it is, not as it will/may be. All victimes of VP
(Validation Psychosis) syndrome do use this fact intensively to cheat
on validator. "Holly hacks" in CSS, <iframe> implantation over
scripting:- it is all to feed into validator a formally valid code
which vould be automatically deployed at runtime into non-so-valid but
functional version.

To check for markup errors client-side HTML Tidy does the trick. If it
is absolutely necessary to know what does W3C think about this code
/exactly/ and /at this given moment/ (as they change their mind rather
often) there is no option but eventually go to

<http://validator.w3.org/>
and
<http://jigsaw.w3.org/css-validator/>
 
D

David Dorward

VK said:
OP wanted something to not run after each change to w3.org This is what
has being said in the post I read and answered.

The OP explicity stated that (a) JavaScript was involved and (b) The
Firefox extension you suggested does not do the job.
I'm missing the point of this exersice. Of course using DOM methods and
even document.write I can bring the runtime document structure in the
state far away from what was originally presented to any validator. So
what's the point?

The point of validation is QA. Presumably the OP wants to maintain that
level of QA as the document is modified by client side scripting (so
that they can identify problems with their script).

Take for example a script which appends "<div><!-- a bunch of a
markup-->" to a document. Since the end tag for the div is missing,
interesting things can happen to the way the document is displayed -
being about to syntax check the generated markup would make it easier
to identify the problem.
Validator of any kind (including the one at w3.org)
checks the document as it is, not as it will/may be. All victimes of VP
(Validation Psychosis) syndrome do use this fact intensively to cheat
on validator. "Holly hacks" in CSS, <iframe> implantation over
scripting:- it is all to feed into validator a formally valid code
which vould be automatically deployed at runtime into non-so-valid but
functional version.

I've no idea what you mean by "<iframe> implantation over scripting",
but my understanding of the Holly Hack is to provide one set of CSS to
some browsers and a different set to others to work around problems
with one group of them - and nothing whatsoever to do with validation.
To check for markup errors client-side HTML Tidy does the trick. If it
is absolutely necessary to know what does W3C think about this code
/exactly/ and /at this given moment/ (as they change their mind rather
often) there is no option but eventually go to

<http://validator.w3.org/>
and
<http://jigsaw.w3.org/css-validator/>

Except that it is rather difficult to get hold of the markup as
modified by client side scripting.
 
V

VK

David said:
Except that it is rather difficult to get hold of the markup as
modified by client side scripting.

Not "difficult" but not possible, this is what I tried to explain.
Validator doesn't take some imaginary "DOM Tree timestamp" - it takes
raw code and sees if a valid DOM tree can be build out of it.

In theory I can imagine a "reverse engineered" validator which
1) uses a tree walker to get the exact DOM structure of the document at
this given moment.
2) Converts each found node to the relevant HTML representation (objDIV
3) Builds up a text document with "restored" HTML code
4) Submits this text document to some validator
5) Validator uses this code to build again DOM tree out of it and to
validate it.

Technically it is possible but AFAIK no one made yet such ridiculous
program (though once again technically it is possible).
 
D

David Dorward

VK said:
David Dorward wrote:

Not "difficult" but not possible

Really? So how does the ViewRenderedSource extension for Firefox get hold of
that then?

http://jennifermadden.com/scripts/ViewRenderedSource.html

From there it isn't a huge step to feeding it through nsgmls or similar.
In theory I can imagine a "reverse engineered" validator which
1) uses a tree walker to get the exact DOM structure of the document at
this given moment.
2) Converts each found node to the relevant HTML representation (objDIV
3) Builds up a text document with "restored" HTML code
4) Submits this text document to some validator
5) Validator uses this code to build again DOM tree out of it and to
validate it.

Congratulations, you've just imagined the "impossible".
Technically it is possible but AFAIK no one made yet such ridiculous
program (though once again technically it is possible).

And it is ridiculous why? I've already explained the practical value of such
a tool.
 
V

VK

David said:
And it is ridiculous why? I've already explained the practical value of such
a tool.

Ridiculous because where to use it? If one retrieves an entire document
over an ajaxoid, then use responseText for validation.

If one adds new elements over createElement/appendChild then on the
level of a single element validation is an over-kill. What ye going to
validate?
var d = document.createElement('DIV');
d.id = 'myDiv';
d.foo = 'bar';
validate(d); // ?

What's the point? You cannot decide yourselve? Also guess what: it is
perfectly valide element. Yes, I added 'foo' property to the DOM
interface, but as an HTML Element it is still perfectly valide
element, unlike if say I would do d.setAtribute('foo', 'bar'); thus if
I would change the DOM Node structure. In either case do you really
need a validator?

Probably it may get some use if one inserts a bounch of HTML mishmash
right into page over innerHTML. In this case maybe... Ridiculous tools
for ridiculous coding... :)
 
D

David Dorward

Ridiculous because where to use it?
If one retrieves an entire document
over an ajaxoid, then use responseText for validation.

If the document can change based on user input, then it may be
significantly easier to test it through a browser rather then construct
the HTTP requests through other methods.
If one adds new elements over createElement/appendChild then on the
level of a single element validation is an over-kill.
What's the point? You cannot decide yourselve?

So everyone is perfect and never makes a mistake when writing/reviewing
code?

That's the point of validation - to catch errors that can be
overlooked.
Probably it may get some use if one inserts a bounch of HTML mishmash
right into page over innerHTML. In this case maybe... Ridiculous tools
for ridiculous coding... :)

I haven't done any testing myself, but I'm told that performing updates
using innerHTML is a /lot/ faster then constructing the DOM piece by
piece.
 
T

Thomas 'PointedEars' Lahn

David said:
I haven't done any testing myself, but I'm told that performing updates
using innerHTML is a /lot/ faster then constructing the DOM piece by
piece.

It depends. As QuirksMode shows, innerHTML can be faster for tables.
However, faster is not necessarily better, since other factors have to
be taken into account, too. Such as interoperability.


PointedEars
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top