protected void doValidate(){
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
try {
IFileEditorInput input = (IFileEditorInput)getEditorInput();
String xml = getDocumentProvider().getDocument(input).get();
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);
}
parser.setFeature("http://xml.org/sax/features/use-entity-resolver2", true);
parser.setEntityResolver(new DTDResolver(getDTDResolvers(),
input.getFile().getLocation().makeAbsolute().toFile().getParentFile()));
parser.setErrorHandler(new XMLValidationHandler(resource));
parser.parse(new InputSource(new StringReader(xml))); //new ByteArrayInputStream(xml.getBytes(charset))));
} catch(Exception ex){