Interface Validator
-
public interface ValidatorValidator of CSS pages through W3C validation API.Retrieve it from
ValidatorBuilderand 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 IGNOREcomment 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 returnTRUE. 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.
- Since:
- 0.1
- See Also:
- W3C API, CSS,
ValidatorBuilder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ValidationResponsevalidate(String content)Validate and return validation response.
-
-
-
Method Detail
-
validate
ValidationResponse validate(String content) throws IOException
Validate and return validation response.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
- Parameters:
content- The HTML/CSS content to validate- Returns:
- The response
- Throws:
IOException- If fails
-
-