use of org.eclipse.wst.dtd.core.internal.emf.DTDElement 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;
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDElement in project webtools.sourceediting by eclipse.
the class DTDModelBuilder method hasIDAttribute.
public boolean hasIDAttribute(DTDAttribute dtdattr) {
boolean hasID = false;
DTDElement element = dtdattr.getDTDElement();
EList attrs = element.getDTDAttribute();
Iterator i = attrs.iterator();
while (i.hasNext()) {
DTDAttribute attr = (DTDAttribute) i.next();
DTDType dType = attr.getDTDType();
if (dType instanceof DTDBasicType) {
if (((DTDBasicType) dType).getKind().getValue() == DTDBasicTypeKind.ID) {
hasID = true;
break;
}
}
}
return hasID;
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDElement in project webtools.sourceediting by eclipse.
the class DTDModelBuilder method addAttlistAndContentModel.
private void addAttlistAndContentModel(DTD dtd, DTDFile dFile) {
// System.out.println("addAttListAndCotentModel - dtd:" +
// dtd.getName());
Enumeration en = dtd.externalElements();
while (en.hasMoreElements()) {
Object e = en.nextElement();
if (e instanceof ElementDecl) {
DTDElement dtdelement = (DTDElement) dtdUtil.getElementPool().get(((ElementDecl) e).getNodeName());
if (dtdelement == null) {
dtdelement = getFactory().createDTDElement();
dtdFile.getDTDObject().add(dtdelement);
}
finishElementDecl(dtdelement, (ElementDecl) e);
} else if (e instanceof Attlist) {
processAttList((Attlist) e);
}
}
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDElement in project webtools.sourceediting by eclipse.
the class DTDUtil method getName.
// This gets the name with pseudo namespace prefixes if dtdFile is not
// null
public static String getName(DTDObject obj, DTDFile dtdFile) {
// $NON-NLS-1$
String name = "";
if (obj instanceof DTDEntity) {
DTDEntity entity = (DTDEntity) obj;
if (dtdFile != null && !entity.getDTDFile().equals(dtdFile)) {
// $NON-NLS-1$
name = new Path(entity.getDTDFile().getName()).lastSegment() + ": ";
}
// $NON-NLS-1$ //$NON-NLS-2$
name += "%" + ((DTDEntity) obj).getName() + ";";
} else if (obj instanceof DTDElement) {
DTDElement element = (DTDElement) obj;
if (dtdFile != null && !element.getDTDFile().equals(dtdFile)) {
// $NON-NLS-1$
name = new Path(element.getDTDFile().getName()).lastSegment() + ": ";
}
name += ((DTDElement) obj).getName();
} else if (obj instanceof DTDElementContent) {
return ((DTDElementContent) obj).getContentName();
}
return name;
}
use of org.eclipse.wst.dtd.core.internal.emf.DTDElement in project webtools.sourceediting by eclipse.
the class DTDModelBuilder method visitElementDecl.
public void visitElementDecl(ElementDecl element) {
// Element might have been added earlier because it is referenced
String declName = element.getNodeName();
// System.out.println("process ElementDecl:" + declName );
DTDElement dtdelement = (DTDElement) dtdUtil.getElementPool().get(declName);
if (dtdelement == null) {
// System.out.println("process ElementDecl - not found - create"
// );
dtdelement = getFactory().createDTDElement();
dtdelement.setName(declName);
dtdFile.getDTDObject().add(dtdelement);
dtdUtil.getElementPool().put(declName, dtdelement);
}
super.visitElementDecl(element);
}
Aggregations