} else {
// this is a complex type
try {
AttributeField attributeField;
Method getterMethod;
Object attributeFieldValue;
QName attributeQName;
for (Iterator iter = type.getAllAttributeFields().iterator(); iter.hasNext();) {
attributeField = (AttributeField) iter.next();
getterMethod = attributeField.getGetterMethod();
attributeFieldValue = getterMethod.invoke(object, new Object[]{});
attributeQName = new QName(attributeField.getNamespace(), attributeField.getName());
// calls to write attribute. for attributes we can have only simple types
if (attributeFieldValue != null) {
writeAttribute(writer,
getSimpleTypeStringValue(attributeField.getType(), attributeFieldValue),
attributeQName,
namespacePrefix);
} else if (attributeField.isRequried()) {
throw new XmlSerializingException("Attribute value for attribute "
+ attributeField.getName() + " is required");
}
}
// write the element fields