Search in sources :

Example 11 with INextCatalog

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

the class BugFixesTest method testInvalidSchemaWithNamespaceInCatalog.

/**
 * Test /BugFixes/XSDRegisteredWithCatalog/InvalidSchemaWithNamespaceInCatalog.xsd
 */
public void testInvalidSchemaWithNamespaceInCatalog() {
    String testname = "InvalidSchemaWithNamespaceInCatalog";
    String testfile = PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + BUGFIXES_DIR + "XSDRegisteredWithCatalog/" + testname + ".xsd";
    String loglocation = PLUGIN_ABSOLUTE_PATH + GENERATED_RESULTS_DIR + BUGFIXES_DIR + "XSDRegisteredWithCatalog/" + testname + ".xsd-log";
    String idealloglocation = PLUGIN_ABSOLUTE_PATH + IDEAL_RESULTS_DIR + BUGFIXES_DIR + "XSDRegisteredWithCatalog/" + testname + ".xsd-log";
    createSimpleProject("Project", new String[] { testfile });
    ICatalog catalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
    for (int i = 0; i < nextCatalogs.length; i++) {
        INextCatalog nextCatalog = nextCatalogs[i];
        if (XMLCorePlugin.USER_CATALOG_ID.equals(nextCatalog.getId())) {
            ICatalog userCatalog = nextCatalog.getReferencedCatalog();
            if (userCatalog != null) {
                ICatalogEntry catalogEntry = (ICatalogEntry) userCatalog.createCatalogElement(ICatalogEntry.ENTRY_TYPE_PUBLIC);
                catalogEntry.setKey("http://www.eclipse.org/webtools/Catalogue");
                catalogEntry.setURI("platform:/resource/Project/InvalidSchemaInXMLCatalog.xsd");
                userCatalog.addCatalogElement(catalogEntry);
                runTest("platform:/resource/Project/InvalidSchemaWithNamespaceInCatalog.xsd", loglocation, idealloglocation);
                catalog.removeCatalogElement(catalogEntry);
            }
        }
    }
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 12 with INextCatalog

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

the class BugFixesTest method testInvalidSchemaInXMLCatalog.

/**
 * Test /BugFixes/InvalidSchemaInXMLCatalog/InvalidSchemaInXMLCatalog.xsd
 */
public void testInvalidSchemaInXMLCatalog() {
    String testname = "InvalidSchemaInXMLCatalog";
    String testfile = PLUGIN_ABSOLUTE_PATH + SAMPLES_DIR + BUGFIXES_DIR + "InvalidSchemaInXMLCatalog/" + testname + ".xsd";
    String loglocation = PLUGIN_ABSOLUTE_PATH + GENERATED_RESULTS_DIR + BUGFIXES_DIR + "InvalidSchemaInXMLCatalog/" + testname + ".xsd-log";
    String idealloglocation = PLUGIN_ABSOLUTE_PATH + IDEAL_RESULTS_DIR + BUGFIXES_DIR + "InvalidSchemaInXMLCatalog/" + testname + ".xsd-log";
    createSimpleProject("Project", new String[] { testfile });
    ICatalog catalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    INextCatalog[] nextCatalogs = catalog.getNextCatalogs();
    for (int i = 0; i < nextCatalogs.length; i++) {
        INextCatalog nextCatalog = nextCatalogs[i];
        if (XMLCorePlugin.USER_CATALOG_ID.equals(nextCatalog.getId())) {
            ICatalog userCatalog = nextCatalog.getReferencedCatalog();
            if (userCatalog != null) {
                ICatalogEntry catalogEntry = (ICatalogEntry) userCatalog.createCatalogElement(ICatalogEntry.ENTRY_TYPE_PUBLIC);
                catalogEntry.setKey("testKey");
                catalogEntry.setURI("http://testuri");
                userCatalog.addCatalogElement(catalogEntry);
                runTest("platform:/resource/Project/InvalidSchemaInXMLCatalog.xsd", /*FILE_PROTOCOL + file.getLocation().toString()*/
                loglocation, idealloglocation);
                catalog.removeCatalogElement(catalogEntry);
            }
        }
    }
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 13 with INextCatalog

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

the class ProjectDescription method getCatalogRecords.

private Collection getCatalogRecords() {
    if (fCatalogRecords == null) {
        List records = new ArrayList();
        ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
        if (defaultCatalog != null) {
            // Process default catalog
            ICatalogEntry[] entries = defaultCatalog.getCatalogEntries();
            for (int entry = 0; entry < entries.length; entry++) {
                ITaglibRecord record = createCatalogRecord(entries[entry]);
                records.add(record);
            }
            // Process declared OASIS nextCatalogs catalog
            INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
            for (int nextCatalog = 0; nextCatalog < nextCatalogs.length; nextCatalog++) {
                ICatalog catalog = nextCatalogs[nextCatalog].getReferencedCatalog();
                ICatalogEntry[] entries2 = catalog.getCatalogEntries();
                for (int entry = 0; entry < entries2.length; entry++) {
                    String uri = entries2[entry].getURI();
                    if (uri != null) {
                        uri = uri.toLowerCase(Locale.US);
                        if (uri.endsWith((".jar")) || uri.endsWith((".tld"))) {
                            ITaglibRecord record = createCatalogRecord(entries2[entry]);
                            if (record != null) {
                                records.add(record);
                            }
                        }
                    }
                }
            }
        }
        fCatalogRecords = records;
    }
    return fCatalogRecords;
}
Also used : ArrayList(java.util.ArrayList) INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) ICatalogEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 14 with INextCatalog

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

the class Catalog method resolveSubordinateCatalogs.

protected String resolveSubordinateCatalogs(int entryType, String publicId, String systemId) throws MalformedURLException, IOException {
    String result = null;
    INextCatalog[] nextCatalogs = getNextCatalogs();
    for (int i = 0; i < nextCatalogs.length; i++) {
        INextCatalog nextCatalog = nextCatalogs[i];
        ICatalog catalog = nextCatalog.getReferencedCatalog();
        if (catalog != null) {
            switch(entryType) {
                case ICatalogEntry.ENTRY_TYPE_PUBLIC:
                    result = catalog.resolvePublic(publicId, systemId);
                    break;
                case ICatalogEntry.ENTRY_TYPE_SYSTEM:
                    result = catalog.resolveSystem(systemId);
                    break;
                case ICatalogEntry.ENTRY_TYPE_URI:
                    result = catalog.resolveURI(systemId);
                    break;
                default:
                    break;
            }
            if (result != null) {
                return result;
            }
        }
    }
    return null;
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 15 with INextCatalog

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

the class CategoryProvider method retrieveCatalog.

private void retrieveCatalog() {
    if (systemCatalog != null)
        return;
    ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
    for (int i = 0; i < nextCatalogs.length; i++) {
        INextCatalog catalog = nextCatalogs[i];
        ICatalog referencedCatalog = catalog.getReferencedCatalog();
        if (referencedCatalog != null) {
            if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) {
                systemCatalog = referencedCatalog;
            }
        }
    }
}
Also used : INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Aggregations

INextCatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog)17 ICatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)13 ICatalogEntry (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry)9 List (java.util.List)6 URL (java.net.URL)4 Catalog (org.eclipse.wst.xml.core.internal.catalog.Catalog)4 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 SoftReference (java.lang.ref.SoftReference)1 HashMap (java.util.HashMap)1 Vector (java.util.Vector)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 Composite (org.eclipse.swt.widgets.Composite)1 ICatalogElement (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement)1 Element (org.w3c.dom.Element)1 NodeList (org.w3c.dom.NodeList)1