public interface Validator
Retrieve it from ValidatorBuilder
and use like this:
HtmlValidator validator = new ValidatorBuilder().css(); ValidationResponse response = validator.validate(text); if (!response.valid()) { // report about a problem }
Sometimes this Jigsaw validator makes mistakes, sometimes you just need to use some IE-specific feature, which is not CSS compliant. In this case you may add comments to the document, at the end of every line you want to ignore during validation, for example:
div.test { color: red; #position: 50%; /* JIGSAW: this is a IE_-related hack */ }
You can also instruct the validator to ingore the entire file, by means
of adding JIGSAW IGNORE
comment anywhere in the text, for example:
/* JIGSAW IGNORE: it's an experimental file */ div.test { something-totally-incorrect:... }
Validation will happen anyway, but ValidationResponse.valid()
will return TRUE
. You will still be able to read errors and warnings
from it, but it will be valid.
Objects of this interface should be immutable and thread-safe.
ValidatorBuilder
Modifier and Type | Method and Description |
---|---|
ValidationResponse |
validate(String content)
Validate and return validation response.
|
ValidationResponse validate(String content) throws IOException
The method should never throw runtime exceptions, no matter what happened with the HTTP connection to the W3C server. It will return an invalid response, but will never throw.
This method expects content of a document which should be validated, not URL to the document
content
- The HTML/CSS content to validateIOException
- If failsCopyright © 2012–2016 jcabi.com. All rights reserved.