public boolean addXsiTypeAndClassIndicatorIfRequired(XMLRecord record, XMLDescriptor xmlDescriptor, XMLDescriptor referenceDescriptor, XMLField xmlField, Object originalObject, Object obj, boolean wasXMLRoot, boolean addToNamespaceResolver){
if(wasXMLRoot){
XMLSchemaReference xmlRef = xmlDescriptor.getSchemaReference();
if(descriptor != null){
XMLRoot xr = (XMLRoot) originalObject;
if (xmlDescriptor.getSchemaReference() == null) {
return false;
}
QName qName = new QName(xr.getNamespaceURI(),xr.getLocalName());
XMLDescriptor xdesc = record.getMarshaller().getXMLContext().getDescriptor(qName);
if (xdesc != null) {
boolean writeTypeAttribute = xdesc.getJavaClass() != descriptor.getJavaClass();
if(writeTypeAttribute && xmlRef != null){
String typeValue = xmlRef.getSchemaContext().substring(1);
writeXsiTypeAttribute(xmlDescriptor, record, typeValue, addToNamespaceResolver);
return true;
}
return false;
}
if(xr.getDeclaredType() != null && xr.getDeclaredType() == xr.getObject().getClass()){
return false;
}
String xmlRootLocalName = xr.getLocalName();
String xmlRootUri = xr.getNamespaceURI();
boolean writeTypeAttribute = true;
for (int i = 0; i < descriptor.getTableNames().size(); i++) {
if (!writeTypeAttribute) {
return false;
}