views:

108

answers:

3

I have a project that generates HTML pages using velocity template and Java. But most of the pages do not comply with W3C standards. How can I validate those HTML pages and get a log telling me what errors/warnings on what pages? Then I can fix the errors manually. I have tried JTidyFilter but that doesn't work for me.

+6  A: 

http://validator.w3.org/

mwhite
It makes me die a little inside that this hasn't been googled before coming here
Alastair Pitts
Don't say that! The anti-LMGTFY police may be listening :-)
Stephen C
I know this and I've tried to set up my own validation server on my windows computer but unfortunately there are some Perl modules missing which seem to be impossible to install in Windows. If it can be set up on Windows I really want to give it a try.
newguy
And where's the automatic (invocable) part?
helios
So how many reposts of this question till you actually die ;)
Thqr
+1  A: 

There is also an experimental API available from W3C to help automate validation. They kindly ask that you throttle requests, and also offer instructions on setting up a validator on a local server. It's definitely more work, but if you're generating a lot of HTML pages, it would probably make sense to also automate the validation.

http://validator.w3.org/docs/api.html

Robert Hui
I'm surprised there is no API for Java. Apart from that I don't really want to modify my source code to add the APIs. All I want to do is to change the configuration file in my J2EE project so that I can turn it on at development time and turn it off when I don't. need it.
newguy
A: 

After extensive research and a little bit code hack, I've managed to use JTidyFilter in my project and it is working beautifully now. JTidyFilter is in JTidyServlet which is a sub-project of JTidy written about 5 years ago. Recently they've updated the codes to comply with Java 5 compiler. I downloaded their codes, upgraded some dependencies and most importantly, changed some lines in the JTidyFilter class which handles the filter and finally got it work nicely in my project.

There are still some issues in reformatting the HTML because I can see 1 or 2 errors when I use firfox HTML validation plugin but otherwise most pages pass the validation.

newguy