IFile resource = input.getFile();
//String charset = resource.getCharset();
//charset = "Shift_JIS";
resource.deleteMarkers(IMarker.PROBLEM,false,0);
HTMLProjectParams params = new HTMLProjectParams(resource.getProject());
if(!params.getValidateXML()){
return;
}
if(params.getUseDTD()==false){
// remove DOCTYPE decl
Matcher matcher = patternDoctypePublic.matcher(xml);
if(matcher.find()){
xml = removeMatched(xml,matcher.start(),matcher.end());
}
matcher = patternDoctypeSystem.matcher(xml);
if(matcher.find()){
xml = removeMatched(xml,matcher.start(),matcher.end());
}
}
SAXParser parser = new SAXParser();
String dtd = getDTD(xml);
String[] xsd = getXSD(xml);
// Validation configuration
if((dtd==null && xsd==null) || !params.getUseDTD()){
parser.setFeature("http://xml.org/sax/features/validation", false);
} else {
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true);
}
if(xsd!=null && params.getUseDTD()){
// parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
// parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", xsd);
parser.setFeature("http://apache.org/xml/features/validation/schema", true);
parser.setFeature("http://xml.org/sax/features/namespaces", true);
}