Search code examples
javahtmlvalidationw3cvelocity

How to validate that HTML matches W3C standards


I have a project that generates HTML pages using a 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.


Solution

  • 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 five 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 one or two errors when I use the Firefox HTML validation plugin, but otherwise most pages pass the validation.