use of nu.validator.checker.LanguageDetectingChecker in project validator by validator.
the class VerifierServletTransaction method validatorByUrl.
/**
* @param url
* @return
* @throws SAXException
* @throws IOException
* @throws IncorrectSchemaException
*/
private Validator validatorByUrl(String url) throws SAXException, IOException, IncorrectSchemaException {
if (loadedValidatorUrls.contains(url)) {
return null;
}
loadedValidatorUrls.add(url);
if ("http://s.validator.nu/xhtml5.rnc".equals(url) || "http://s.validator.nu/html5.rnc".equals(url) || "http://s.validator.nu/html5-all.rnc".equals(url) || "http://s.validator.nu/xhtml5-all.rnc".equals(url) || "http://s.validator.nu/html5-its.rnc".equals(url) || "http://s.validator.nu/xhtml5-rdfalite.rnc".equals(url) || "http://s.validator.nu/html5-rdfalite.rnc".equals(url)) {
errorHandler.setSpec(html5spec);
}
Schema sch = resolveSchema(url, jingPropertyMap);
Validator validator = sch.createValidator(jingPropertyMap);
ContentHandler validatorContentHandler = validator.getContentHandler();
if (validatorContentHandler instanceof XmlPiChecker) {
lexicalHandler = (LexicalHandler) validatorContentHandler;
}
if (validatorContentHandler instanceof Assertions) {
Assertions assertions = (Assertions) validatorContentHandler;
assertions.setRequest(request);
assertions.setSourceIsCss(sourceCode.getIsCss());
}
if (validatorContentHandler instanceof LanguageDetectingChecker) {
//
LanguageDetectingChecker langdetect = (LanguageDetectingChecker) validatorContentHandler;
langdetect.setRequest(request);
langdetect.setHttpContentLanguageHeader(request.getHeader("Content-Language"));
}
return validator;
}
Aggregations