XSObjectList attrUses = attrGrp.getAttributeUses();
int useCount = attrUses.getLength();
XSAttributeUseImpl currUse;
XSAttributeDecl currDecl;
short constType;
ValidatedInfo defaultValue;
boolean isSpecified;
QName attName;
// for each attribute use
for (int i = 0; i < useCount; i++) {
currUse = (XSAttributeUseImpl)attrUses.item(i);
currDecl = currUse.fAttrDecl;
// get value constraint
constType = currUse.fConstraintType;
defaultValue = currUse.fDefault;
if (constType == XSConstants.VC_NONE) {
constType = currDecl.getConstraintType();
defaultValue = currDecl.fDefault;
}
// whether this attribute is specified
isSpecified = attributes.getValue(currDecl.fTargetNamespace, currDecl.fName) != null;
// Element Locally Valid (Complex Type)
// 4 The {attribute declaration} of each attribute use in the {attribute uses} whose
// {required} is true matches one of the attribute information items in the element
// information item's [attributes] as per clause 3.1 above.
if (currUse.fUse == SchemaSymbols.USE_REQUIRED) {
if (!isSpecified)
reportSchemaError("cvc-complex-type.4", new Object[]{element.rawname, currDecl.fName});
}
// if the attribute is not specified, then apply the value constraint
if (!isSpecified && constType != XSConstants.VC_NONE) {
attName = new QName(null, currDecl.fName, currDecl.fName, currDecl.fTargetNamespace);
String normalized = (defaultValue!=null)?defaultValue.stringValue():"";
int attrIndex = attributes.addAttribute(attName, "CDATA", normalized);
if (attributes instanceof XMLAttributesImpl) {
XMLAttributesImpl attrs = (XMLAttributesImpl)attributes;
boolean schemaId = defaultValue != null &&
defaultValue.memberType != null ?