Search in sources :

Example 11 with ICatalog

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();
}
Also used : ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog) IDelegateCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog) File(java.io.File)

Example 12 with ICatalog

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);
    }
}
Also used : ISuffixEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 13 with ICatalog

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);
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog) ContentModelManager(org.eclipse.wst.xml.core.internal.contentmodel.ContentModelManager)

Example 14 with ICatalog

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());
        }
    }
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) List(java.util.List) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 15 with ICatalog

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Aggregations

ICatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)32 INextCatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog)14 ICatalogEntry (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry)8 List (java.util.List)6 IDelegateCatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 IFile (org.eclipse.core.resources.IFile)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 Composite (org.eclipse.swt.widgets.Composite)2 Catalog (org.eclipse.wst.xml.core.internal.catalog.Catalog)2 CatalogSet (org.eclipse.wst.xml.core.internal.catalog.CatalogSet)2 IRewriteEntry (org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry)2 ISuffixEntry (org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry)2 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)2 ContentModelManager (org.eclipse.wst.xml.core.internal.contentmodel.ContentModelManager)2 NodeList (org.w3c.dom.NodeList)2