[英]Open-source Java library for HTML5 validation?
Is there any good open-source Java library for HTML5 validation? 有没有用于HTML5验证的好的开源Java库? It would be great if it did CSS 3 validation too. 如果它也进行CSS 3验证会很棒。 JTidy has not been maintained for a while. JTidy还没有维持一段时间。
The source code for both the W3C HTML and CSS validators is available, though only the CSS one is written in Java. 可以使用W3C HTML和CSS验证器的源代码,但只有CSS编写的是Java编写的。 The repo for validator.nu is here , that is written in Java. validator.nu的repo就在这里 ,用Java编写。
However you should note that HTML5 validation is different to that for previous versions of HTML. 但是,您应该注意HTML5验证与以前版本的HTML不同。 Previous versions of HTML depended on a DTD and followed an SGML validation model, HTML5 no longer has a DTD or any link to SGML. 以前版本的HTML依赖于DTD并遵循SGML验证模型,HTML5不再具有DTD或任何指向SGML的链接。 It's possible that what you want is not an HTML5 validator, but an HTML5 linter . 你想要的可能不是HTML5验证器,而是HTML5 linter 。
validator.nu is open source. validator.nu是开源的。 No CSS parsing though. 虽然没有CSS解析。
Asking the same question myself, I see there is a project called jcabi
which implements a very simple validation interface in Java. 自己问同样的问题,我看到有一个名为jcabi
的项目,它在Java中实现了一个非常简单的验证接口。
http://w3c.jcabi.com http://w3c.jcabi.com
Very simple example based on their GIT readme: 基于GIT自述文件的非常简单的示例:
import com.jcabi.w3c.HtmlValidator;
assert ValidatorBuilder
.html()
.validate("<html>hello!</html>")
.valid()
;
It appears to check against a remote service (which seems like overkill depending on what you are doing), though you could install your own local instance. 虽然您可以安装自己的本地实例,但它似乎是针对远程服务进行检查(这看起来有点过分取决于您正在做什么)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.