}
}
}
public void writeSingleValue(Object element, Object parent, XMLRecord row, AbstractSession session) {
XMLField xmlRootField = null;
Object originalObject = element;
DOMRecord record = (DOMRecord) row;
Node root = record.getDOM();
org.w3c.dom.Document doc = row.getDocument();
boolean wasXMLRoot = false;
if (usesXMLRoot() && (element instanceof XMLRoot)) {
wasXMLRoot = true;
xmlRootField = new XMLField();
XPathFragment frag = new XPathFragment();
if ((((XMLRoot) element)).getRootFragment().getNamespaceURI() != null) {
frag.setNamespaceURI(((XMLRoot) element).getNamespaceURI());
} else {
frag.setXPath(((XMLRoot) element).getLocalName());
}
xmlRootField.setXPathFragment(frag);
xmlRootField.setNamespaceResolver(row.getNamespaceResolver());
element = ((XMLRoot) element).getObject();
}
if (element instanceof String) {
writeSimpleValue(xmlRootField, element, originalObject, record, doc, root, wasXMLRoot, session);
} else if (element instanceof org.w3c.dom.Node) {
Node importedCopy = doc.importNode((Node) element, true);
root.appendChild(importedCopy);
} else {
XMLDescriptor referenceDescriptor = (XMLDescriptor) session.getDescriptor(element.getClass());
if (referenceDescriptor == null) {
writeSimpleValue(xmlRootField, element, originalObject, record, doc, root, wasXMLRoot, session);
return;
}
if (wasXMLRoot) {
if (((XMLRoot) originalObject).getRootFragment().getNamespaceURI() != null) {
String prefix = referenceDescriptor.getNonNullNamespaceResolver().resolveNamespaceURI(((XMLRoot) originalObject).getNamespaceURI());
if ((prefix == null) || prefix.equals("")) {
prefix = record.getNamespaceResolver().resolveNamespaceURI(((XMLRoot) originalObject).getRootFragment().getNamespaceURI());
}
if ((prefix == null) || prefix.equals("")) {
xmlRootField.getXPathFragment().setGeneratedPrefix(true);
prefix = record.getNamespaceResolver().generatePrefix();
}
xmlRootField.getXPathFragment().setXPath(prefix + ":" + ((XMLRoot) originalObject).getLocalName());
}
}
DOMRecord nestedRecord = (DOMRecord) buildCompositeRow(element, session, referenceDescriptor, row, xmlRootField, originalObject, wasXMLRoot);
if (nestedRecord != null) {