use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class TestCatalogRetrivalAndModelCreation method testCatalog11DelegateUri.
public void testCatalog11DelegateUri() throws MalformedURLException, IOException {
ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
IDelegateCatalog uriDelegate = (IDelegateCatalog) xmlCatalog.createCatalogElement(IDelegateCatalog.DELEGATE_TYPE_URI);
File delegateCat = makeTempFile("delegateUri", "<catalog xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\">\r\n" + " <uri name=\"urn:funky:dog\" uri=\"file:///funky-dog.dtd\"/>\r\n" + " <uriSuffix uriSuffix=\":cat\" uri=\"file:///smellycat.dtd\"/>\r\n" + " <rewriteURI uriStartString=\"urn:funky:fish:\" rewritePrefix=\"file:///dtds/\"/>\r\n" + "</catalog>");
uriDelegate.setStartString("urn:funky:");
uriDelegate.setCatalogLocation(delegateCat.toURI().toString());
xmlCatalog.addCatalogElement(uriDelegate);
try {
assertEquals("uri entry", "file:///funky-dog.dtd", xmlCatalog.resolveURI("urn:funky:dog"));
assertEquals("uriSuffix entry", "file:///smellycat.dtd", xmlCatalog.resolveURI("urn:funky:where-is-my:cat"));
assertEquals("rewriteUri entry", "file:///dtds/parrot.dtd", xmlCatalog.resolveURI("urn:funky:fish:parrot.dtd"));
} finally {
xmlCatalog.removeCatalogElement(uriDelegate);
}
delegateCat.delete();
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class TestCatalogRetrivalAndModelCreation method testCatalog11UriSuffix.
public void testCatalog11UriSuffix() throws MalformedURLException, IOException {
ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
ISuffixEntry uriSuffix = (ISuffixEntry) xmlCatalog.createCatalogElement(ISuffixEntry.SUFFIX_TYPE_URI);
uriSuffix.setSuffix("XMLSchema.xsd");
uriSuffix.setURI(LOCAL_SCHEMA_FILE);
xmlCatalog.addCatalogElement(uriSuffix);
try {
String resolved = xmlCatalog.resolveURI("http://www.w3.org/2001/XMLSchema.xsd");
assertEquals(LOCAL_SCHEMA_FILE, resolved);
} finally {
xmlCatalog.removeCatalogElement(uriSuffix);
}
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class TestCatalogRetrivalAndModelCreation method doURI_CMTest.
void doURI_CMTest(String EXPECTED_URI) throws MalformedURLException, IOException {
ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
String resolved = xmlCatalog.resolveURI(EXPECTED_URI);
assertNotNull("expected to find " + EXPECTED_URI, resolved);
ContentModelManager contentModelManager = ContentModelManager.getInstance();
CMDocument contentModel = contentModelManager.createCMDocument(resolved, null);
assertNotNull("expected to create content model for " + EXPECTED_URI, contentModel);
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class CatalogContributorRegistryReaderTest method testReadRegistry.
public final void testReadRegistry() throws Exception {
assertNotNull(defaultCatalog);
assertEquals(XMLCorePlugin.DEFAULT_CATALOG_ID, defaultCatalog.getId());
assertEquals(2, defaultCatalog.getNextCatalogs().length);
String pluginId = TestPlugin.getDefault().getBundle().getSymbolicName();
// test system entries
assertNotNull(systemCatalog);
List entries = CatalogTest.getCatalogEntries(systemCatalog, ICatalogEntry.ENTRY_TYPE_SYSTEM);
for (int i = 0; i < entries.size(); i++) {
ICatalogEntry entry = (ICatalogEntry) entries.get(i);
if ("testSystemId".equals(entry.getId())) {
String resolvedURI = resolvePath(pluginId, "data/Personal/personal.dtd");
assertEquals(resolvedURI, entry.getURI());
assertEquals("http://personal/personal.dtd", entry.getKey());
}
}
// test public entries
entries = CatalogTest.getCatalogEntries(systemCatalog, ICatalogEntry.ENTRY_TYPE_PUBLIC);
for (int i = 0; i < entries.size(); i++) {
ICatalogEntry entry = (ICatalogEntry) entries.get(i);
if ("testPublicId1".equals(entry.getId())) {
String resolvedURI = resolvePath(pluginId, "data/Invoice/Invoice.dtd");
assertEquals(resolvedURI, entry.getURI());
assertEquals("InvoiceId_test", entry.getKey());
// test user defined attributes
assertEquals("http://org.eclipse.wst.xml.example/Invoice.dtd", entry.getAttributeValue("webURL"));
} else if ("testMappingInfo".equals(entry.getId())) {
String resolvedURI = resolvePath(pluginId, "platform:/plugin/org.eclipse.xsd/cache/www.w3.org/2001/XMLSchema.xsd");
assertEquals(resolvedURI, entry.getURI());
assertEquals("http://www.w3.org/2001/XMLSchema1", entry.getKey());
}
}
// test uri entries
entries = CatalogTest.getCatalogEntries(systemCatalog, ICatalogEntry.ENTRY_TYPE_URI);
for (int i = 0; i < entries.size(); i++) {
ICatalogEntry entry = (ICatalogEntry) entries.get(i);
if ("testURIId1".equals(entry.getId())) {
String resolvedURI = resolvePath(pluginId, "data/example/example.xsd");
assertEquals(resolvedURI, entry.getURI());
assertEquals("http://apache.org/xml/xcatalog/example", entry.getKey());
} else if ("testURIId2".equals(entry.getId())) {
String resolvedURI = resolvePath(pluginId, "platform:/plugin/org.eclipse.xsd/cache/www.w3.org/2001/XMLSchema.xsd");
assertEquals(resolvedURI, entry.getURI());
assertEquals("http://www.w3.org/2001/XMLSchema", entry.getKey());
} else if ("testURIId3".equals(entry.getId())) {
String resolvedURI = resolvePath(pluginId, "jar:platform:/plugin/org.eclipse.wst.xml.catalog.tests/data/schemas.jar!/data/catalog.xsd");
assertEquals(resolvedURI, entry.getURI());
assertEquals("http://oasis.names.tc.entity.xmlns.xml.catalog", entry.getKey());
}
}
// test tested catalog
INextCatalog[] nextCatalogEntries = systemCatalog.getNextCatalogs();
for (int i = 0; i < nextCatalogEntries.length; i++) {
INextCatalog nextCatalogEntry = (INextCatalog) nextCatalogEntries[i];
if ("testNestedCatalog".equals(nextCatalogEntry.getId())) {
String resolvedURI = resolvePath(pluginId, "data/catalog1.xml");
assertEquals(resolvedURI, nextCatalogEntry.getCatalogLocation());
ICatalog nextCatalog = nextCatalogEntry.getReferencedCatalog();
assertNotNull(nextCatalog);
assertEquals(3, nextCatalog.getCatalogEntries().length);
// test public entries
entries = CatalogTest.getCatalogEntries(nextCatalog, ICatalogEntry.ENTRY_TYPE_PUBLIC);
assertEquals(1, entries.size());
ICatalogEntry entry = (ICatalogEntry) entries.get(0);
// URI uri = URIHelper.getURIForFilePath(resolvedURI);
// resolvedURI = URIHelper.makeAbsolute(uri.toURL(), "./Invoice/Invoice.dtd");
assertEquals(getFileLocation("data/Invoice/Invoice.dtd"), entry.getURI());
assertEquals("InvoiceId_test", entry.getKey());
// test system entries
entries = CatalogTest.getCatalogEntries(nextCatalog, ICatalogEntry.ENTRY_TYPE_SYSTEM);
assertEquals(1, entries.size());
entry = (ICatalogEntry) entries.get(0);
assertEquals(getFileLocation("data/Invoice/Invoice.dtd"), entry.getURI());
assertEquals("Invoice.dtd", entry.getKey());
// test uri entries
entries = CatalogTest.getCatalogEntries(nextCatalog, ICatalogEntry.ENTRY_TYPE_URI);
assertEquals(1, entries.size());
entry = (ICatalogEntry) entries.get(0);
assertEquals(getFileLocation("data/Invoice/Invoice.dtd"), entry.getURI());
assertEquals("http://www.test.com/Invoice.dtd", entry.getKey());
}
}
}
use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.
the class SelectXMLCatalogIdDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogArea, XMLCommonUIContextIds.XCUI_CATALOG_DIALOG);
ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
panel = new SelectXMLCatalogIdPanel(dialogArea, xmlCatalog);
ISelectionChangedListener listener = new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateButtonState();
}
};
panel.getTableViewer().setFilterExtensions(extensions);
panel.getTableViewer().addSelectionChangedListener(listener);
return dialogArea;
}
Aggregations