Search in sources :

Example 16 with ICatalog

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

the class XMLHyperlinkDetector method getCatalogEntry.

/**
 * @param uriString
 * @return
 */
private ICatalogEntry getCatalogEntry(String uriString) {
    ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    if (defaultCatalog != null) {
        // Process default catalog
        ICatalogEntry[] entries = defaultCatalog.getCatalogEntries();
        for (int entry = 0; entry < entries.length; entry++) {
            if (uriString.equals(entries[entry].getKey()) || uriString.equals(entries[entry].getURI())) {
                return entries[entry];
            }
        }
        // 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++) {
                if (uriString.equals(entries2[entry].getKey()) || uriString.equals(entries2[entry].getURI()))
                    return entries2[entry];
            }
        }
    }
    return null;
}
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 17 with ICatalog

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

the class CommonAddNamespacesDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);
    addNamespacesControl = new CommonAddNamespacesControl(dialogArea, SWT.NONE, resourceLocation);
    List list = new ArrayList();
    addBuiltInNamespaces(list);
    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.USER_CATALOG_ID.equals(referencedCatalog.getId())) {
                ICatalog userCatalog = referencedCatalog;
                addCatalogMapToList(userCatalog, list);
            } else if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) {
                ICatalog systemCatalog = referencedCatalog;
                addCatalogMapToList(systemCatalog, list);
            }
        }
    }
    computeAddablePrefixes(list, existingNamespaces);
    addNamespacesControl.setNamespaceInfoList(list);
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ArrayList(java.util.ArrayList) INextCatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog) ArrayList(java.util.ArrayList) List(java.util.List) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Example 18 with ICatalog

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog 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 19 with ICatalog

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog 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 20 with ICatalog

use of org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog 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)

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