Search in sources :

Example 1 with DTDEntity

use of org.eclipse.wst.dtd.core.internal.emf.DTDEntity in project webtools.sourceediting by eclipse.

the class DTDModelBuilder method visitExternalEntityDecl.

public void visitExternalEntityDecl(EntityDecl entity) {
    DTDEntity dtdEntity = createDTDEntity(entity);
    // System.out.println("adding entity: " + declName);
    DTDExternalEntity extEntity = getFactory().createDTDExternalEntity();
    dtdEntity.setContent(extEntity);
    finishExternalEntity(extEntity, entity);
    // System.out.println(" ext entity toMof: " );
    if (dtdEntity.isParameterEntity()) {
        // $NON-NLS-1$ //$NON-NLS-2$
        dtdUtil.getPEPool().put("%" + entity.getNodeName() + ";", dtdEntity);
    }
    super.visitExternalEntityDecl(entity);
}
Also used : DTDExternalEntity(org.eclipse.wst.dtd.core.internal.emf.DTDExternalEntity) DTDEntity(org.eclipse.wst.dtd.core.internal.emf.DTDEntity)

Example 2 with DTDEntity

use of org.eclipse.wst.dtd.core.internal.emf.DTDEntity in project webtools.sourceediting by eclipse.

the class DTDModelBuilder method finishAttribute.

// Stuff for populating attribute
public void finishAttribute(DTDAttribute dtdattr, AttNode attdef) {
    boolean parseError = false;
    if (attdef.name.startsWith("%")) {
        // $NON-NLS-1$
        String peName = attdef.name.trim();
        DTDEntity en = (DTDEntity) dtdUtil.getPEPool().get(peName);
        if (en != null) {
            dtdattr.setAttributeNameReferencedEntity(en);
        }
    }
    dtdattr.setName(attdef.name);
    int attrType = attdef.getDeclaredType();
    if (attrType == AttNode.PEREFERENCE && attdef.type != null) {
        String peName = attdef.type.trim();
        DTDEntity en = (DTDEntity) dtdUtil.getPEPool().get(peName);
        if (en != null) {
            dtdattr.setAttributeTypeReferencedEntity(en);
            // hack,
            setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
        // so
        // we
        // can
        // get
        // back
        // the
        // default
        // value
        } else
            // set default type
            setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
    } else {
        switch(attrType) {
            case AttNode.CDATA:
                setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
                break;
            case AttNode.ENTITIES:
                setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ENTITIES());
                break;
            case AttNode.ENTITY:
                setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ENTITY());
                break;
            case AttNode.ID:
                // check for duplicate ID attribute
                if (hasIDAttribute(dtdattr)) {
                    /*String errMsg = DTDCoreMessages._ERROR_DUP_ID_ATTRIBUTE_1; //$NON-NLS-1$
						errMsg += attdef.name + DTDCoreMessages._UI_ERRORPART_DUP_ID_ATTRIBUTE_2; //$NON-NLS-1$*/
                    // dtdattr.getDTDElement().getIElement().setDTDErrorMessage(errMsg);
                    // dtdattr.getDTDElement().getDTDFile().setParseError(true);
                    parseError = true;
                }
                setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ID());
                break;
            case AttNode.IDREF:
                setAttrDTDType(dtdattr, getFactory().getDTDBasicType_IDREF());
                break;
            case AttNode.IDREFS:
                setAttrDTDType(dtdattr, getFactory().getDTDBasicType_IDREFS());
                break;
            case AttNode.ENUMERATION:
                setAttrDTDType(dtdattr, createDTDEnumeration(dtdattr, attdef, DTDEnumGroupKind.NAME_TOKEN_GROUP));
                break;
            case AttNode.NOTATION:
                setAttrDTDType(dtdattr, createDTDEnumeration(dtdattr, attdef, DTDEnumGroupKind.NOTATION_GROUP));
                break;
            case AttNode.NMTOKEN:
                setAttrDTDType(dtdattr, getFactory().getDTDBasicType_NMTOKEN());
                break;
            case AttNode.NMTOKENS:
                setAttrDTDType(dtdattr, getFactory().getDTDBasicType_NMTOKENS());
                break;
            default:
        }
    }
    int attrDefault = attdef.getDefaultType();
    int defaultKind = DTDDefaultKind.IMPLIED;
    switch(attrDefault) {
        case AttNode.FIXED:
            defaultKind = DTDDefaultKind.FIXED;
            break;
        case AttNode.IMPLIED:
            defaultKind = DTDDefaultKind.IMPLIED;
            break;
        case AttNode.REQUIRED:
            defaultKind = DTDDefaultKind.REQUIRED;
            break;
        case AttNode.NOFIXED:
            defaultKind = DTDDefaultKind.NOFIXED;
            break;
        default:
    }
    DTDDefaultKind defaultKindObj = DTDDefaultKind.get(defaultKind);
    dtdattr.setDefaultKind(defaultKindObj);
    if (parseError) {
        return;
    }
    String defaultValue = attdef.defaultValue;
    if (defaultValue != null) {
        if (attrType == AttNode.ENUMERATION || attrType == AttNode.NOTATION) {
            if (!isDefaultEnumValueValid(attdef, defaultValue)) {
                // dtdattr.getDTDElement().getDTDFile().setParseError(true);
                return;
            }
        }
        dtdattr.setDefaultValueString(defaultValue);
    }
// System.out.println("DTDAttr - toMof getDefaultValueString " +
// getDefaultValueString());
// System.out.println("DTDAttr - toMof getDefaultValue: " +
// getDefaultValue());
}
Also used : DTDDefaultKind(org.eclipse.wst.dtd.core.internal.emf.DTDDefaultKind) DTDEntity(org.eclipse.wst.dtd.core.internal.emf.DTDEntity)

Example 3 with DTDEntity

use of org.eclipse.wst.dtd.core.internal.emf.DTDEntity in project webtools.sourceediting by eclipse.

the class DTDModelBuilder method createDTDEntity.

public DTDEntity createDTDEntity(EntityDecl entity) {
    // create and do what we can to fill in some basic things
    DTDEntity dtdEntity = getFactory().createDTDEntity();
    dtdFile.getDTDObject().add(dtdEntity);
    dtdEntity.setName(entity.getNodeName());
    dtdEntity.setParameterEntity(entity.isParameter());
    if (entity.getComment() != null) {
        dtdEntity.setComment(entity.getComment());
    }
    if (entity.getErrorMessage() != null) {
        addErrorMessage(entity.getErrorMessage(), dtdEntity);
    }
    return dtdEntity;
}
Also used : DTDEntity(org.eclipse.wst.dtd.core.internal.emf.DTDEntity)

Example 4 with DTDEntity

use of org.eclipse.wst.dtd.core.internal.emf.DTDEntity in project webtools.sourceediting by eclipse.

the class DTDModelBuilder method visitInternalEntityDecl.

public void visitInternalEntityDecl(EntityDecl entity) {
    DTDEntity dtdEntity = createDTDEntity(entity);
    DTDInternalEntity intEntity = getFactory().createDTDInternalEntity();
    dtdEntity.setContent(intEntity);
    intEntity.setValue(entity.getValue());
    // System.out.println(" int entity toMof: " );
    if (dtdEntity.isParameterEntity()) {
        // $NON-NLS-1$ //$NON-NLS-2$
        dtdUtil.getPEPool().put("%" + entity.getNodeName() + ";", dtdEntity);
    }
    super.visitInternalEntityDecl(entity);
}
Also used : DTDEntity(org.eclipse.wst.dtd.core.internal.emf.DTDEntity) DTDInternalEntity(org.eclipse.wst.dtd.core.internal.emf.DTDInternalEntity)

Example 5 with DTDEntity

use of org.eclipse.wst.dtd.core.internal.emf.DTDEntity in project webtools.sourceediting by eclipse.

the class DTDAttributeImpl method unparse.

public String unparse() {
    StringBuffer result = new StringBuffer(128);
    result.append(getName());
    StringBuffer value = new StringBuffer();
    switch(getDefaultKind().getValue()) {
        case DTDDefaultKind.IMPLIED:
            // $NON-NLS-1$
            value.append("#IMPLIED");
            break;
        case DTDDefaultKind.REQUIRED:
            // $NON-NLS-1$
            value.append("#REQUIRED");
            break;
        case DTDDefaultKind.FIXED:
            String type = getDTDType().toString();
            if (!(type.equals(DTDType.ID) || type.equals(DTDType.IDREF) || type.equals(DTDType.ENUM_NAME_TOKEN_GROUP) || type.equals(DTDType.IDREFS))) {
                // $NON-NLS-1$ //$NON-NLS-2$
                value.append("#FIXED \"").append(getDefaultValueString()).append("\"");
            }
            break;
        case DTDDefaultKind.NOFIXED:
            String defaultValue = getDefaultValueString();
            if (defaultValue != null)
                // $NON-NLS-1$ //$NON-NLS-2$
                value.append("\"").append(defaultValue).append("\"");
            break;
    }
    // Get the attribute type
    DTDEntity typeEnt = getAttributeTypeReferencedEntity();
    if (typeEnt != null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        result.append(" %" + typeEnt.getName() + "; ").append(value);
    } else {
        DTDType dtdType = getDTDType();
        if (dtdType instanceof DTDBasicType) {
            switch(((DTDBasicType) dtdType).getKind().getValue()) {
                case DTDBasicTypeKind.CDATA:
                    // $NON-NLS-1$
                    result.append(" CDATA ").append(value);
                    break;
                case DTDBasicTypeKind.ID:
                    // $NON-NLS-1$
                    result.append(" ID ").append(value);
                    break;
                case DTDBasicTypeKind.IDREF:
                    // $NON-NLS-1$
                    result.append(" IDREF ").append(value);
                    break;
                case DTDBasicTypeKind.IDREFS:
                    // $NON-NLS-1$
                    result.append(" IDREFS ").append(value);
                    break;
                case DTDBasicTypeKind.ENTITY:
                    // $NON-NLS-1$
                    result.append(" ENTITY ").append(value);
                    break;
                case DTDBasicTypeKind.ENTITIES:
                    // $NON-NLS-1$
                    result.append(" ENTITIES ").append(value);
                    break;
                case DTDBasicTypeKind.NMTOKEN:
                    // $NON-NLS-1$
                    result.append(" NMTOKEN ").append(value);
                    break;
                case DTDBasicTypeKind.NMTOKENS:
                    // $NON-NLS-1$
                    result.append(" NMTOKENS ").append(value);
                    break;
            }
        } else if (dtdType instanceof DTDEnumerationType) {
            // $NON-NLS-1$
            result.append(" ").append(buildEnumString((DTDEnumerationType) dtdType)).append(value);
        }
    }
    return result.toString();
}
Also used : DTDBasicType(org.eclipse.wst.dtd.core.internal.emf.DTDBasicType) DTDEnumerationType(org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType) DTDType(org.eclipse.wst.dtd.core.internal.emf.DTDType) DTDEntity(org.eclipse.wst.dtd.core.internal.emf.DTDEntity)

Aggregations

DTDEntity (org.eclipse.wst.dtd.core.internal.emf.DTDEntity)14 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)4 DTDElement (org.eclipse.wst.dtd.core.internal.emf.DTDElement)3 DTDElementReferenceContent (org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent)2 DTDEntityReferenceContent (org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent)2 DTDGroupContent (org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent)2 DTDGroupKind (org.eclipse.wst.dtd.core.internal.emf.DTDGroupKind)2 DTDOccurrenceType (org.eclipse.wst.dtd.core.internal.emf.DTDOccurrenceType)2 DTDPCDataContent (org.eclipse.wst.dtd.core.internal.emf.DTDPCDataContent)2 CMBasicNode (org.eclipse.wst.dtd.core.internal.saxparser.CMBasicNode)2 CMGroupNode (org.eclipse.wst.dtd.core.internal.saxparser.CMGroupNode)2 CMNode (org.eclipse.wst.dtd.core.internal.saxparser.CMNode)2 CMReferenceNode (org.eclipse.wst.dtd.core.internal.saxparser.CMReferenceNode)2 Collection (java.util.Collection)1 Enumeration (java.util.Enumeration)1 Iterator (java.util.Iterator)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 DTDAnyContent (org.eclipse.wst.dtd.core.internal.emf.DTDAnyContent)1 DTDBasicType (org.eclipse.wst.dtd.core.internal.emf.DTDBasicType)1