private AttributeBinding bindAttribute(XSAttributeUse attrUse)
{
XSAttributeDeclaration attr = attrUse.getAttrDeclaration();
QName attrName = new QName(attr.getNamespace(), attr.getName());
XSSimpleTypeDefinition attrType = attr.getTypeDefinition();
TypeBinding typeBinding = bindSimpleType(attrType);
if (trace)
{
log.trace("binding attribute " + attrName + ", required=" + attrUse.getRequired());
}
AttributeBinding binding = new AttributeBinding(schema, attrName, typeBinding, DefaultHandlers.ATTRIBUTE_HANDLER);
binding.setRequired(attrUse.getRequired());
if(attrUse.getConstraintType() == XSConstants.VC_DEFAULT)
{
// Associate the default value with the binding
binding.setDefaultConstraint(attrUse.getConstraintValue());
}
if (processAnnotations)
{
XSAnnotation an = attr.getAnnotation();
if(an != null)
{
if (trace)
{
log.trace(attrName + " attribute annotation");
}
XsdAnnotation xsdAn = XsdAnnotation.unmarshal(an.getAnnotationString());
XsdAppInfo appInfo = xsdAn.getAppInfo();
if(appInfo != null)
{
PropertyMetaData propertyMetaData = appInfo.getPropertyMetaData();
if(propertyMetaData != null)
{
binding.setPropertyMetaData(propertyMetaData);
}
boolean mapEntryKey = appInfo.isMapEntryKey();
if(mapEntryKey)
{
binding.setMapEntryKey(mapEntryKey);
}
boolean mapEntryValue = appInfo.isMapEntryValue();
if(mapEntryValue)
{
binding.setMapEntryValue(mapEntryValue);
}
}
}
}
if (trace)
{
String msg = "bound attribute " + attrName;
if(binding.getPropertyMetaData() != null)
{
msg += " property=" +
binding.getPropertyMetaData().getName() +
", collectionType=" + binding.getPropertyMetaData().getCollectionType();
}
else if(binding.isMapEntryKey())
{
msg += "bound as a key in a map entry";
}
else if(binding.isMapEntryValue())
{
msg += "bound as a value in a map entry";
}
else
{
msg += " type=" + attrType.getName();
}
if(binding.getDefaultConstraint() != null)
{
msg += ", default=" + binding.getDefaultConstraint();