private static void bindAttributes(SchemaBinding doc,
TypeBinding type,
XSAttributeUse attrUse)
{
XSAttributeDeclaration attr = attrUse.getAttrDeclaration();
XSSimpleTypeDefinition attrType = attr.getTypeDefinition();
TypeBinding typeBinding = bindSimpleType(doc, attrType);
QName attrName = new QName(attr.getNamespace(), attr.getName());
AttributeBinding binding = type.addAttribute(attrName, typeBinding, RtAttributeHandler.INSTANCE);
if( attrUse.getConstraintType() == XSConstants.VC_DEFAULT )
{
// Associate the default value with the binding
binding.setDefaultConstraint(attrUse.getConstraintValue());
}
XSAnnotation an = attr.getAnnotation();
if(an != null)
{
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(log.isTraceEnabled())
{
String msg = "attribute " +
new QName(attr.getNamespace(), attr.getName()) +
": ";
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() + ", owner type=" + type.getQName();
}
if(binding.getDefaultConstraint() != null)
{
msg += ", default=" + binding.getDefaultConstraint();