IDOMAttr xmlattr = (IDOMAttr) a;
if (!xmlattr.isGlobalAttr())
continue; // skip futher validation and begin next loop.
}
CMAttributeDeclaration adec = (CMAttributeDeclaration) declarations.getNamedItem(a.getName());
final String attrName = a.getName().toLowerCase(Locale.US);
/* Check the modelquery if nothing is declared by the element declaration */
if (adec == null) {
if (modelQueryNodes == null)
modelQueryNodes = ModelQueryUtil.getModelQuery(target.getOwnerDocument()).getAvailableContent((Element) node, edec, ModelQuery.INCLUDE_ATTRIBUTES);
for (int k = 0; k < modelQueryNodes.size(); k++) {
CMNode cmnode = (CMNode) modelQueryNodes.get(k);
if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION && cmnode.getNodeName().toLowerCase(Locale.US).equals(attrName)) {
adec = (CMAttributeDeclaration) cmnode;
break;
}
}
}
if (adec == null) {
if ((attrName.startsWith(ATTR_NAME_DATA) && attrName.length() > ATTR_NAME_DATA_LENGTH) || (attrName.startsWith(ATTR_NAME_USER_AGENT_FEATURE) && attrName.length() > ATTR_NAME_USER_AGENT_FEATURE_LENGTH))
continue;
// No attr declaration was found. That is, the attr name is
// undefined.
// but not regard it as undefined name if it includes nested
// region
if (!hasNestedRegion(((IDOMNode) a).getNameRegion())) {
rgnType = REGION_NAME;
state = ErrorState.UNDEFINED_NAME_ERROR;
}
} else {
// The attr declaration was found.
// At 1st, the name should be checked.
if (CMUtil.isObsolete(adec)){
state = ErrorState.OBSOLETE_ATTR_NAME_ERROR;
}
if (CMUtil.isHTML(edec) && (!CMUtil.isXHTML(edec))) {
// If the target element is pure HTML (not XHTML), some
// attributes
// might be written in boolean format. It should be check
// specifically.
if (CMUtil.isBooleanAttr(adec) && ((IDOMAttr) a).hasNameOnly())
continue; // OK, keep going. No more check is needed
// against this attr.
} else {
// If the target is other than pure HTML (JSP or XHTML),
// the name
// must be checked exactly (ie in case sensitive way).
String actual = a.getName();
String desired = adec.getAttrName();
if (!actual.equals(desired)) { // case mismatch
rgnType = REGION_NAME;
state = ErrorState.MISMATCHED_ERROR;
}
}
// 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;