if (ctx.trace)
{
log.trace("binding attribute " + attrName + " for " + type.getQName() + ", required=" + attrUse.getRequired());
}
XSSimpleTypeDefinition attrType = attr.getTypeDefinition();
TypeBinding typeBinding = bindSimpleType(ctx, attrType);
AttributeBinding binding = type.addAttribute(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 (ctx.processAnnotations)
{
XSAnnotation an = attr.getAnnotation();
if(an != null)
{
if (ctx.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 (ctx.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() + ", owner type=" + type.getQName();
}
if(binding.getDefaultConstraint() != null)
{
msg += ", default=" + binding.getDefaultConstraint();