}
}
// Then, the value must be checked.
if (state == ErrorState.NONE_ERROR) { // Need more check.
// Now, the value should be checked, if the type is ENUM.
CMDataType attrType = adec.getAttrType();
if (a instanceof IDOMAttr) {
final ITextRegion region = ((IDOMAttr) a).getEqualRegion();
if (region == null) {
rgnType = REGION_NAME;
state = ErrorState.MISSING_ATTR_VALUE_EQUALS_ERROR;
}
}
String actualValue = a.getValue();
if (attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) {
// Check FIXED value.
String validValue = attrType.getImpliedValue();
if (!actualValue.equals(validValue)) {
rgnType = REGION_VALUE;
state = ErrorState.UNDEFINED_VALUE_ERROR;
}
}
else if (CMDataType.URI.equals(attrType.getDataTypeName())) {
// TODO: URI validation?
if (false && actualValue.indexOf('#') < 0 && actualValue.indexOf(":/") == -1 && CMUtil.isHTML(edec)) { //$NON-NLS-1$ //$NON-NLS-2$
IStructuredDocumentRegion start = ((IDOMNode) node).getStartStructuredDocumentRegion();
if (start != null && start.getFirstRegion().getTextLength() == 1) {
IPath basePath = new Path(((IDOMNode) node).getModel().getBaseLocation());
if (basePath.segmentCount() > 1) {
IPath path = ModuleCoreSupport.resolve(basePath, actualValue);
IResource found = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
if (found == null || !found.isAccessible()) {
rgnType = REGION_VALUE;
state = ErrorState.RESOURCE_NOT_FOUND;
}
}
}
}
}
else if (CMDataType.ENUM.equals(attrType.getDataTypeName())) {
/*
* Check current value is valid among a known list.
* There may be enumerated values provided even when
* the datatype is not ENUM, but we'll only validate
* against that list if the type matches.
*/
String[] enumeratedValues = attrType.getEnumeratedValues();
// several candidates are found.
boolean found = false;
for (int j = 0; j < enumeratedValues.length; j++) {
// At 1st, compare ignoring case.
if (actualValue.equalsIgnoreCase(enumeratedValues[j])) {