mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-27620 XML Catalog support: resolve system
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.javaee;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.apache.xml.resolver.Catalog;
|
||||
import org.apache.xml.resolver.CatalogManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -73,7 +74,10 @@ public class XMLCatalogManager {
|
||||
@Nullable
|
||||
public String resolve(String uri) {
|
||||
try {
|
||||
return myManager.getCatalog().resolvePublic(uri, null);
|
||||
Catalog catalog = myManager.getCatalog();
|
||||
if (catalog == null) return null;
|
||||
String resolved = catalog.resolveSystem(uri);
|
||||
return resolved == null ? catalog.resolvePublic(uri, null) : resolved;
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.warn(e);
|
||||
|
||||
@@ -42,12 +42,18 @@ public class XMLCatalogManagerTest extends LightPlatformCodeInsightFixtureTestCa
|
||||
assertTrue(filePath, new File(new URI(filePath)).exists());
|
||||
}
|
||||
|
||||
public void testResolve() throws Exception {
|
||||
public void testResolvePublic() throws Exception {
|
||||
String resolve = getManager().resolve("-//W3C//DTD XHTML 1.0 Strict//EN");
|
||||
assertNotNull(resolve);
|
||||
assertTrue(resolve, resolve.endsWith("/catalog/xhtml1-strict.dtd"));
|
||||
}
|
||||
|
||||
public void testResolveSystem() throws Exception {
|
||||
String resolve = getManager().resolve("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
|
||||
assertNotNull(resolve);
|
||||
assertTrue(resolve, resolve.endsWith("/catalog/xhtml1-strict.dtd"));
|
||||
}
|
||||
|
||||
private XMLCatalogManager getManager() throws IOException {
|
||||
return new XMLCatalogManager(getTestDataPath() + "catalog.properties");
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
|
||||
<public publicId="-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
uri="xhtml1-strict.dtd"/>
|
||||
|
||||
<system systemId="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
||||
uri="xhtml1-strict.dtd"/>
|
||||
</catalog>
|
||||
Reference in New Issue
Block a user