IDEA-27620 XML Catalog support: resolve system

This commit is contained in:
Dmitry Avdeev
2012-07-23 18:14:28 +04:00
parent b8ede5fdeb
commit 675cbdc507
3 changed files with 14 additions and 3 deletions
@@ -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");
}
+2 -1
View File
@@ -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>