Search in sources :

Example 1 with IRewriteEntry

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

the class CatalogWriter method processRewriteEntries.

private void processRewriteEntries(ICatalog catalog, Element parent) {
    IRewriteEntry[] catalogEntries = catalog.getRewriteEntries();
    for (int i = 0; i < catalogEntries.length; i++) {
        IRewriteEntry entry = catalogEntries[i];
        String startString = entry.getStartString();
        String prefix = entry.getRewritePrefix();
        Element childElement = null;
        switch(entry.getEntryType()) {
            case IRewriteEntry.REWRITE_TYPE_SYSTEM:
                childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_REWRITE_SYSTEM);
                if (childElement != null) {
                    childElement.setAttribute(OASISCatalogConstants.ATTR_SYSTEM_ID_START_STRING, startString);
                    childElement.setAttribute(OASISCatalogConstants.ATTR_REWRITE_PREFIX, prefix);
                }
                break;
            case IRewriteEntry.REWRITE_TYPE_URI:
                childElement = parent.getOwnerDocument().createElement(OASISCatalogConstants.TAG_REWRITE_URI);
                if (childElement != null) {
                    childElement.setAttribute(OASISCatalogConstants.ATTR_URI_START_STRING, startString);
                    childElement.setAttribute(OASISCatalogConstants.ATTR_REWRITE_PREFIX, prefix);
                }
                break;
            default:
                break;
        }
        if (childElement != null) {
            setAttributes(entry, childElement);
            parent.appendChild(childElement);
        }
    }
}
Also used : Element(org.w3c.dom.Element) ICatalogElement(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement) IRewriteEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry)

Example 2 with IRewriteEntry

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

Example 3 with IRewriteEntry

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

the class TestCatalogRetrivalAndModelCreation method testCatalog11RewriteUri.

public void testCatalog11RewriteUri() throws MalformedURLException, IOException {
    ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
    IRewriteEntry uriSuffix = (IRewriteEntry) xmlCatalog.createCatalogElement(IRewriteEntry.REWRITE_TYPE_URI);
    uriSuffix.setStartString("urn:fisk:");
    uriSuffix.setRewritePrefix(LOCAL_SCHEMA_DIR);
    xmlCatalog.addCatalogElement(uriSuffix);
    try {
        String resolved = xmlCatalog.resolveURI("urn:fisk:example.dtd");
        assertEquals(LOCAL_SCHEMA_DIR_REWRITTEN, resolved);
    } finally {
        xmlCatalog.removeCatalogElement(uriSuffix);
    }
}
Also used : IRewriteEntry(org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry) ICatalog(org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog)

Aggregations

IRewriteEntry (org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry)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