mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-141538 XML validator does not use a relative path to the XSD
This commit is contained in:
+3
-1
@@ -153,7 +153,9 @@ public class ValidateXmlActionHandler {
|
||||
|
||||
public void doParse() {
|
||||
try {
|
||||
myParser.parse(new InputSource(new StringReader(myFile.getText())), new DefaultHandler() {
|
||||
InputSource inputSource = new InputSource(new StringReader(myFile.getText()));
|
||||
inputSource.setSystemId(myFile.getVirtualFile().getUrl().replace("file:", "file:/"));
|
||||
myParser.parse(inputSource, new DefaultHandler() {
|
||||
@Override
|
||||
public void warning(SAXParseException e) throws SAXException {
|
||||
if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.WARNING);
|
||||
|
||||
@@ -40,6 +40,7 @@ import java.io.StringReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -225,21 +226,16 @@ public class XmlResourceResolver implements XMLEntityResolver {
|
||||
xmlResourceIdentifier.getLiteralSystemId():
|
||||
xmlResourceIdentifier.getNamespace();
|
||||
|
||||
if (publicId != null) {
|
||||
if (publicId != null && publicId.startsWith("file:")) {
|
||||
Path basePath = new File(URI.create(xmlResourceIdentifier.getBaseSystemId())).getParentFile().toPath();
|
||||
try {
|
||||
String userDir = new File(System.getProperty("user.dir")).toURI().getPath();
|
||||
String publicIdPath = new URI(publicId).getPath();
|
||||
if (publicIdPath.startsWith(userDir)) {
|
||||
publicId = publicIdPath.substring(publicIdPath.indexOf(userDir) + userDir.length());
|
||||
}
|
||||
Path publicIdPath = new File(URI.create(publicId)).toPath();
|
||||
publicId = basePath.relativize(publicIdPath).toString().replace(File.separatorChar, '/');
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
PsiFile psiFile = resolve(xmlResourceIdentifier.getBaseSystemId(), publicId);
|
||||
if (psiFile == null && xmlResourceIdentifier.getBaseSystemId() != null) {
|
||||
psiFile = ExternalResourceManager.getInstance().getResourceLocation(xmlResourceIdentifier.getBaseSystemId(), myFile, null);
|
||||
}
|
||||
if (psiFile==null && xmlResourceIdentifier.getLiteralSystemId()!=null && xmlResourceIdentifier.getNamespace()!=null) {
|
||||
psiFile = resolve(
|
||||
xmlResourceIdentifier.getBaseSystemId(),
|
||||
@@ -274,6 +270,7 @@ public class XmlResourceResolver implements XMLEntityResolver {
|
||||
}
|
||||
}
|
||||
source.setPublicId(publicId);
|
||||
source.setBaseSystemId(null);
|
||||
source.setCharacterStream(new StringReader(psiFile.getText()));
|
||||
|
||||
return source;
|
||||
|
||||
Reference in New Issue
Block a user