0.13.3 10-Apr-2014

W3C Validator in Java

It’s simple (see JavaDoc for more details):

public class My {
  public void main() {
    String xhtml = "<html><body><p>Hello, world!</p></body></html>";
    ValidationResponse response = new ValidatorBuilder().html().validate(xhtml);
    assert response.valid();
  }
}

Similar mechanism for CSS:

public class My {
  public void main() {
    String css = "body { font-family: Arial; }";
    ValidationResponse response = new ValidatorBuilder().css().validate(css);
    assert response.valid();
  }
}

This dependency you add to pom.xml (or download rexsl-w3c.jar):

<dependency>
  <groupId>com.rexsl</groupId>
  <artifactId>rexsl-w3c</artifactId>
  <version>0.13.3</version>
</dependency>

All events are logged through slf4j, using "com.rexsl.w3c" logger. If you want to see them, just add proper binding to classpath, as explained in SLF4J manual.

built by maven