Search in sources :

Example 1 with Assertions

use of nu.validator.checker.schematronequiv.Assertions 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;
}
Also used : LanguageDetectingChecker(nu.validator.checker.LanguageDetectingChecker) Schema(com.thaiopensource.validate.Schema) CheckerSchema(nu.validator.checker.jing.CheckerSchema) XmlPiChecker(nu.validator.checker.XmlPiChecker) Assertions(nu.validator.checker.schematronequiv.Assertions) Validator(com.thaiopensource.validate.Validator) CombineValidator(com.thaiopensource.relaxng.impl.CombineValidator) CombineContentHandler(nu.validator.xml.CombineContentHandler) ContentHandler(org.xml.sax.ContentHandler)

Aggregations

CombineValidator (com.thaiopensource.relaxng.impl.CombineValidator)1 Schema (com.thaiopensource.validate.Schema)1 Validator (com.thaiopensource.validate.Validator)1 LanguageDetectingChecker (nu.validator.checker.LanguageDetectingChecker)1 XmlPiChecker (nu.validator.checker.XmlPiChecker)1 CheckerSchema (nu.validator.checker.jing.CheckerSchema)1 Assertions (nu.validator.checker.schematronequiv.Assertions)1 CombineContentHandler (nu.validator.xml.CombineContentHandler)1 ContentHandler (org.xml.sax.ContentHandler)1