public void insertDefaultAttributes(IDOMElement element) {
List<CMAttributeDeclaration> decls = getAttributeDeclarations(element);
for (CMAttributeDeclaration decl : decls) {
if (decl.getUsage() == CMAttributeDeclaration.REQUIRED) {
String attrName = decl.getAttrName();
CMDataType attrType = decl.getAttrType();
String attrValue = element.getAttribute(attrName);
// We don't want to overwrite an existing value.
if (attrValue == null || attrValue.trim().length() == 0) {
if (attrType != null) {
if (attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE
&& attrType.getImpliedValue() != null) {
attrValue = attrType.getImpliedValue();
}
else if (attrType.getEnumeratedValues() != null && attrType.getEnumeratedValues().length > 0) {
attrValue = attrType.getEnumeratedValues()[0];
}
}
element.setAttribute(attrName, attrValue);
}
}