Well formed validation of XHTML pages

Validating XHTML pages is an interesting subject because no high traffic site I’ve ever tried it on actually successfully validates XHTML against a W3C validator. Most folks I know take it for granted that it’s unrealistic to write large sites with 100% W3C validating XHTML. However, that presents a real problem on the software engineering side where we want to be able to rely on our development environment or continuous integration to tell us whether everything is truly working and valid! For example with continuous integration we can run unit tests, functional tests, checkstyle on the code, compile the JSP’s, etc… but we can’t validate our XHTML because it’s unrealistic. So for the time being at work we’ve settled for validating well-formedness by using JSPX and TAGX for templating.

JSPX or TAGX serve an important purpose in that they will fail to compile if the XHTML is not well formed XML. If you forget to close a tag or close tags out of order you know right away! Realistically I think well-formedness of HTML templates is the best we can do right now given 100% XHTML validation seems unrealistic, otherwise, it would be great to build XHTML validation of pages into the continuous integration process.

I’m always bummed that other templating languages such as Tapestry’s templates, Ruby’s RHTML, Perl’s Mason, Python’s Zope, etc… don’t offer validation of well-formedness. JSP is the only templating language that I’m aware of that will tell you if the HTML you’ve written is well-formed XML. That’s too bad, since I really prefer the purity of a Tapestry or Enhydra’s XMLC templating approach over the JSP, RHTML, etc… approaches. Oh well, you can’t have it all!

This entry was posted in Java, Software Engineering, Web. Bookmark the permalink.

One Response to Well formed validation of XHTML pages