Search in sources :

Example 1 with ISuffixEntry

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

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

the class CatalogWriter method processSuffixEntries.

private void processSuffixEntries(ICatalog catalog, Element parent) {
    ISuffixEntry[] suffixEntries = catalog.getSuffixEntries();
    for (int i = 0; i < suffixEntries.length; i++) {
        ISuffixEntry entry = suffixEntries[i];
        String suffixString = entry.getSuffix();
        String uri = entry.getURI();
        Element childElement = null;
        switch(entry.getEntryType()) {
            case ISuffixEntry.SUFFIX_TYPE_SYSTEM:
                childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_SYSTEM_SUFFIX);
                if (childElement != null) {
                    childElement.setAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID_SUFFFIX, suffixString);
                    childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
                }
                break;
            case ISuffixEntry.SUFFIX_TYPE_URI:
                childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_URI_SUFFIX);
                if (childElement != null) {
                    childElement.setAttribute(OASISCatalogConstants.ATTR_URI_SUFFIX, suffixString);
                    childElement.setAttribute(OASISCatalogConstants.ATTR_URI, uri);
                }
                break;
            default:
                break;
        }
        if (childElement != null) {
            setAttributes(entry, childElement);
            parent.appendChild(childElement);
        }
    }
}
Also used : ISuffixEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry) Element(org.w3c.dom.Element) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement)

Example 3 with ISuffixEntry

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

Aggregations

ISuffixEntry (org.eclipse.wst.xml.core.internal.catalog.provisional.ISuffixEntry)3 ICatalog (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)2 ICatalogElement (org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement)1 Element (org.w3c.dom.Element)1