writeOutMappings(record, object, session);
// If this descriptor is involved in inheritance add the class type.
if (isXmlDescriptor()) {
XMLDescriptor xmlDescriptor = (XMLDescriptor)getDescriptor();
XMLSchemaReference xmlRef = xmlDescriptor.getSchemaReference();
if (shouldWriteXsiType) {
writeXsiTypeAttribute(xmlDescriptor, (DOMRecord)record, xmlRef.getSchemaContext().substring(1));
}
if (getDescriptor().hasInheritance()) {
if ((record.getLeafElementType() != null) && ((xmlRef.getType() == 1) && xmlRef.isGlobalDefinition())) {
// only interested in global COMPLEX_TYPE
QName ctxQName = xmlRef.getSchemaContextAsQName(xmlDescriptor.getNamespaceResolver());
if (ctxQName.equals(record.getLeafElementType())) {
// don't write out xsi:type attribute
} else {
// write out the target descriptor's schema context as xsi:type
XMLField xmlField = (XMLField)xmlDescriptor.getInheritancePolicy().getClassIndicatorField();
if (xmlField.getLastXPathFragment().isAttribute()) {
writeXsiTypeAttribute(xmlDescriptor, (DOMRecord)record, xmlRef.getSchemaContext().substring(1));
} else {
writeXsiTypeAttribute(xmlDescriptor, (DOMRecord)record, xmlRef.getSchemaContext().substring(1));
}
}
// if the user has set the element type, but the target descriptor's
// schema context in not a global complex type or is null, delegate