Search in sources :

Example 26 with ICatalog

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.

the class TestCatalogRetrivalAndModelCreation method doCMTest.

private void doCMTest(String EXPECTED_PUBLICID) throws MalformedURLException, IOException {
    ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    String resolved = xmlCatalog.resolvePublic(EXPECTED_PUBLICID, null);
    ContentModelManager contentModelManager = ContentModelManager.getInstance();
    CMDocument contentModel = contentModelManager.createCMDocument(resolved, null);
    assertNotNull("expected to create content model for " + EXPECTED_PUBLICID, 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 27 with ICatalog

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.

the class TestCatalogRetrivalAndModelCreation method doTest.

private void doTest(String EXPECTED_PUBLICID) throws MalformedURLException, IOException {
    ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    String resolved = xmlCatalog.resolvePublic(EXPECTED_PUBLICID, null);
    assertNotNull("expected to find " + EXPECTED_PUBLICID, resolved);
}
Also used : ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 28 with ICatalog

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.

the class TestCatalogRetrivalAndModelCreation method testCatalog11DelegatePublic.

public void testCatalog11DelegatePublic() throws MalformedURLException, IOException {
    ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    IDelegateCatalog publicDelegate = (IDelegateCatalog) xmlCatalog.createCatalogElement(IDelegateCatalog.DELEGATE_TYPE_PUBLIC);
    // Ironically, we don't use WTP's Resolver when loading the catalog XML.
    // Adding <!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.example.org/dtd/catalog.dtd">
    // to the catalog below will make the loading fail...
    File delegateCat = makeTempFile("delegatePublic", "<catalog xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\"\r\n" + "       prefer=\"public\">\r\n" + "    <public publicId=\"-//Example//an example V1.0.0//EN\"\r\n" + "            uri=\"file:///example.dtd\"/>\r\n" + "</catalog>");
    publicDelegate.setStartString("-//Example//");
    publicDelegate.setCatalogLocation(delegateCat.toURI().toString());
    xmlCatalog.addCatalogElement(publicDelegate);
    try {
        String resolved = xmlCatalog.resolvePublic("-//Example//an example V1.0.0//EN", "example.dtd");
        assertEquals("file:///example.dtd", resolved);
    } finally {
        xmlCatalog.removeCatalogElement(publicDelegate);
    }
    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 29 with ICatalog

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.

the class TestCatalogRetrivalAndModelCreation method testCatalog11SystemSuffix.

public void testCatalog11SystemSuffix() throws MalformedURLException, IOException {
    ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    ISuffixEntry systemSuffix = (ISuffixEntry) xmlCatalog.createCatalogElement(ISuffixEntry.SUFFIX_TYPE_SYSTEM);
    systemSuffix.setSuffix("XMLSchema.xsd");
    systemSuffix.setURI(LOCAL_SCHEMA_FILE);
    xmlCatalog.addCatalogElement(systemSuffix);
    try {
        String resolved = xmlCatalog.resolveSystem("http://www.w3.org/2001/XMLSchema.xsd");
        assertEquals(LOCAL_SCHEMA_FILE, resolved);
    } finally {
        xmlCatalog.removeCatalogElement(systemSuffix);
    }
}
Also used : ISuffixEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 30 with ICatalog

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog in project webtools.sourceediting by eclipse.

the class TestCatalogRetrivalAndModelCreation method testCatalog11RewriteSystem.

public void testCatalog11RewriteSystem() throws MalformedURLException, IOException {
    ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    IRewriteEntry systemSuffix = (IRewriteEntry) xmlCatalog.createCatalogElement(IRewriteEntry.REWRITE_TYPE_SYSTEM);
    systemSuffix.setStartString("http://www.example.org/dtds/");
    systemSuffix.setRewritePrefix(LOCAL_SCHEMA_DIR);
    xmlCatalog.addCatalogElement(systemSuffix);
    try {
        String resolved = xmlCatalog.resolveSystem("http://www.example.org/dtds/example.dtd");
        assertEquals(LOCAL_SCHEMA_DIR_REWRITTEN, resolved);
    } finally {
        xmlCatalog.removeCatalogElement(systemSuffix);
    }
}
Also used : IRewriteEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry) 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