Search in sources :

Example 1 with ErrorMessage

use of org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage in project webtools.sourceediting by eclipse.

the class DTDModelBuilder method createOrFindElement.

/**
 * Find the real element that is referenced by the current element
 */
private DTDElement createOrFindElement(String name, Object obj) {
    // DTDElement aElement = getDTDFile().findElement(name);
    DTDElement aElement = (DTDElement) dtdUtil.getElementPool().get(name);
    if (aElement != null) {
        return aElement;
    }
    // $NON-NLS-1$
    String errorMsg = DTDCoreMessages._ERROR_UNDECLARED_ELEMENT_1;
    // $NON-NLS-1$ //$NON-NLS-2$
    errorMsg += "\"" + name + "\"";
    // $NON-NLS-1$
    errorMsg += DTDCoreMessages._UI_ERRORPART_UNDECLARED_ELEMENT_2;
    ErrorMessage dtdError = new ErrorMessage();
    dtdError.setErrorMessage(errorMsg);
    addErrorMessage(dtdError, obj);
    // System.out.println(errorMsg);
    // setDTDErrorMessage(errorMsg);
    getDTDFile().setParseError(true);
    // 
    // Create an empty element for the reference to make it valid
    // 
    DTDFactory factory = getFactory();
    DTDElement dtdelement = factory.createDTDElement();
    dtdelement.setName(name);
    DTDEmptyContent emptyContent = factory.createDTDEmptyContent();
    dtdelement.setContent(emptyContent);
    getDTDFile().getDTDObject().add(dtdelement);
    dtdUtil.getElementPool().put(name, dtdelement);
    return dtdelement;
}
Also used : DTDElement(org.eclipse.wst.dtd.core.internal.emf.DTDElement) ErrorMessage(org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage) DTDFactory(org.eclipse.wst.dtd.core.internal.emf.DTDFactory) DTDEmptyContent(org.eclipse.wst.dtd.core.internal.emf.DTDEmptyContent)

Example 2 with ErrorMessage

use of org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage in project webtools.sourceediting by eclipse.

the class DTDModelBuilder method updateSystemID.

/**
 * The SystemID attribute is set to whatever the user enters e.g.
 * com/ibm/b2b/xmimodels/xxx.dtd.xmi
 *
 * In the unparse() method, parse out the DTD file name from the classpath
 * name. e.g. returns xxx.dtd
 */
private void updateSystemID(DTDExternalEntity extEntity, EntityDecl entityDecl) {
    String systemId = entityDecl.getSystemId();
    String publicId = entityDecl.getPublicId();
    if (systemId != null) {
        URIResolver idResolver = URIResolverPlugin.createResolver();
        String uri = idResolver.resolve(dtd.getName(), publicId, systemId);
        ExternalDTDModel ed = dtdUtil.getExternalDTDModel(resources, uri);
        if (ed != null) {
            DTDFile referenceDtdFile = ed.getExternalDTDFile();
            extEntity.setEntityReferencedFromAnotherFile(referenceDtdFile);
            extEntity.setSystemID(systemId);
        } else {
            if (entityDecl.getErrorMessage() == null) {
                ErrorMessage dtdError = new ErrorMessage();
                // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                dtdError.setErrorMessage(DTDCoreMessages._ERROR_INCL_FILE_LOAD_FAILURE + " '" + systemId + "'");
                addErrorMessage(dtdError, extEntity.getDTDEntity());
            }
            if (systemId != null) {
                extEntity.setSystemID(systemId);
            } else {
                // $NON-NLS-1$
                extEntity.setSystemID("");
            }
        }
    } else // end of if ()
    {
        // set the system id to be ""
        // $NON-NLS-1$
        extEntity.setSystemID("");
    }
}
Also used : URIResolver(org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver) ErrorMessage(org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage) DTDFile(org.eclipse.wst.dtd.core.internal.emf.DTDFile)

Aggregations

ErrorMessage (org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage)2 URIResolver (org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver)1 DTDElement (org.eclipse.wst.dtd.core.internal.emf.DTDElement)1 DTDEmptyContent (org.eclipse.wst.dtd.core.internal.emf.DTDEmptyContent)1 DTDFactory (org.eclipse.wst.dtd.core.internal.emf.DTDFactory)1 DTDFile (org.eclipse.wst.dtd.core.internal.emf.DTDFile)1