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);
}
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());
}
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;
}
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);
}
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();
}
Aggregations