An open source Java library for HTML5 validation?

Is there a good open source Java library for HTML5 validation? It would be great if he also did a CSS 3 check. JTidy has not been supported for a while.

+6
source share
3 answers

The source code is for W3C HTML and CSS , but only one CSS is written in Java. repo for validator.nu here , written in Java.

However, you should notice that HTML5 validation is different from validation of previous versions of HTML. Previous versions of HTML depended on DTDs and followed the SGML validation model; HTML5 no longer has DTDs or any reference to SGML. It is possible that you do not want an HTML5 validator, but an HTML5 linter .

+4
source

validator.nu is open source. However, CSS analysis is not performed.

+1
source

Asking the same question, I see that there is a project called jcabi that implements a very simple validation interface in Java.

http://w3c.jcabi.com

A very simple example based on their GIT readme:

 import com.jcabi.w3c.HtmlValidator; assert ValidatorBuilder .html() .validate("<html>hello!</html>") .valid() ; 

It seems to be checking the remote service (which seems redundant depending on what you are doing), although you can install your own local instance.

0
source

Source: https://habr.com/ru/post/920178/


All Articles