Search in sources :

Example 6 with ICatalog

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

Example 7 with ICatalog

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

Example 8 with ICatalog

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();
}
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 9 with ICatalog

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

Example 10 with ICatalog

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);
}
Also used : 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