From 675cbdc50717815b4425df321ad220f13997ba03 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Mon, 23 Jul 2012 15:57:39 +0400 Subject: [PATCH] IDEA-27620 XML Catalog support: resolve system --- xml/impl/src/com/intellij/javaee/XMLCatalogManager.java | 6 +++++- xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java | 8 +++++++- xml/tests/testData/catalog/catalog.xml | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/xml/impl/src/com/intellij/javaee/XMLCatalogManager.java b/xml/impl/src/com/intellij/javaee/XMLCatalogManager.java index fbc0e5037017..c9eacea92662 100644 --- a/xml/impl/src/com/intellij/javaee/XMLCatalogManager.java +++ b/xml/impl/src/com/intellij/javaee/XMLCatalogManager.java @@ -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); diff --git a/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java b/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java index 4309b2e7110d..630642fb3620 100644 --- a/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java +++ b/xml/tests/src/com/intellij/xml/XMLCatalogManagerTest.java @@ -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"); } diff --git a/xml/tests/testData/catalog/catalog.xml b/xml/tests/testData/catalog/catalog.xml index acb48871b955..2618424db905 100644 --- a/xml/tests/testData/catalog/catalog.xml +++ b/xml/tests/testData/catalog/catalog.xml @@ -4,5 +4,6 @@ - + \ No newline at end of file