use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class ImportXMLCatalogWizard method performFinish.
public boolean performFinish() {
IFile file = importPage.getFile();
if (file != null) {
String fileName = file.getLocation().toFile().toURI().toString();
try {
CatalogSet tempResourceSet = new CatalogSet();
// $NON-NLS-1$
ICatalog newCatalog = tempResourceSet.lookupOrCreateCatalog("temp", fileName);
workingUserCatalog.addEntriesFromCatalog(newCatalog);
userCatalog.clear();
userCatalog.addEntriesFromCatalog(workingUserCatalog);
userCatalog.save();
} catch (Exception e) {
return false;
}
}
return true;
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class TestCatalogRetrivalAndModelCreation method testXHTML11_xmlresolver.
/**
* We expect the XMLCatalogResolver and XMLCatalogIdResolver
* to resolve to the same URI given a public id in our catalog.
*
* @throws MalformedURLException
* @throws IOException
*/
public void testXHTML11_xmlresolver() throws MalformedURLException, IOException {
String EXPECTED_PUBLICID = "-//W3C//DTD XHTML 1.1//EN";
// bug 117424, here ewe make up a base location to satisfy the resolver API
// that expects a non-null base location
String baseLocation = "http://www.example.org/testXHTML11.xml";
XMLCatalogIdResolver resolver = new XMLCatalogIdResolver(baseLocation, null);
String resolvedXML_Id = resolver.resolve(baseLocation, EXPECTED_PUBLICID, null);
ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
String resolvedXL_Cat = xmlCatalog.resolvePublic(EXPECTED_PUBLICID, null);
assertEquals(resolvedXL_Cat, resolvedXML_Id);
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class TestCatalogRetrivalAndModelCreation method testCatalog11DelegateSystem.
public void testCatalog11DelegateSystem() throws MalformedURLException, IOException {
ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
IDelegateCatalog systemDelegate = (IDelegateCatalog) xmlCatalog.createCatalogElement(IDelegateCatalog.DELEGATE_TYPE_SYSTEM);
File delegateCat = makeTempFile("delegateSystem", "<catalog xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\">\r\n" + " <system systemId=\"http://funky.org/dog\" uri=\"file:///funky-dog.dtd\"/>\r\n" + " <systemSuffix systemIdSuffix=\"/cat.dtd\" uri=\"file:///smellycat.xsd\"/>\r\n" + " <rewriteSystem systemIdStartString=\"http://funky.org/parrots/\" rewritePrefix=\"file:///dtds/parrots/\"/>\r\n" + "</catalog>");
systemDelegate.setStartString("http://funky.org/");
systemDelegate.setCatalogLocation(delegateCat.toURI().toString());
xmlCatalog.addCatalogElement(systemDelegate);
try {
assertEquals("try systemId entry", "file:///funky-dog.dtd", xmlCatalog.resolveSystem("http://funky.org/dog"));
assertEquals("try systemSuffix entry", "file:///smellycat.xsd", xmlCatalog.resolveSystem("http://funky.org/some/cat.dtd"));
assertEquals("try rewriteSystem entry", "file:///dtds/parrots/macaw.xsd", xmlCatalog.resolveSystem("http://funky.org/parrots/macaw.xsd"));
} finally {
xmlCatalog.removeCatalogElement(systemDelegate);
}
delegateCat.delete();
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class TestCatalogRetrivalAndModelCreation method doURITest.
private void doURITest(String EXPECTED_URI) throws MalformedURLException, IOException {
ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
String resolved = xmlCatalog.resolveURI(EXPECTED_URI);
assertNotNull("expected to find " + EXPECTED_URI, resolved);
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class TestCatalogRetrivalAndModelCreation method testKnownNotExist.
/**
* Test that a known error case returns null.
*
* @throws MalformedURLException
* @throws IOException
*/
public void testKnownNotExist() throws MalformedURLException, IOException {
String JUNK_STRING = "doesNotExistTest";
ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
String resolved = xmlCatalog.resolvePublic(JUNK_STRING, null);
assertNull("expected no match for " + JUNK_STRING, resolved);
}
Aggregations