}
protected Node objectToXMLNode(Object object, Node rootNode, AbstractSession session,XMLDescriptor descriptor, boolean isXMLRoot) throws XMLMarshalException {
DocumentPreservationPolicy docPresPolicy = xmlContext.getDocumentPreservationPolicy(session);
if (docPresPolicy != null && docPresPolicy.shouldPreserveDocument()) {
XMLRecord xmlRow = null;
if (!isXMLRoot) {
xmlRow = (XMLRecord) ((XMLObjectBuilder) descriptor.getObjectBuilder()).createRecordFor(object, xmlContext.getDocumentPreservationPolicy(session));
xmlRow.setMarshaller(this);
if (getAttachmentMarshaller() != null) {
xmlRow.setXOPPackage(getAttachmentMarshaller().isXOPPackage());
}
if (xmlRow.getDOM().getNodeType() == Node.ELEMENT_NODE) {
addDescriptorNamespacesToXMLRecord(descriptor, xmlRow);
}
}
Document doc = objectToXML(object, rootNode, descriptor, xmlRow, isXMLRoot, docPresPolicy);
if ((xmlRow != null) && (xmlRow.getDOM().getNodeType() == Node.DOCUMENT_FRAGMENT_NODE)) {
return xmlRow.getDOM();
} else {
return doc;
}
}
MarshalRecord marshalRecord = new NodeRecord();