// Add the new element node
legacyXmlElement.getParentNode().insertBefore(namespaceJndiElement, legacyXmlElement);
// Format the new element node
IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
CleanupProcessorXML cleanupProcessor = new CleanupProcessorXML();
cleanupProcessor.getCleanupPreferences().setCompressEmptyElementTags(true);
formatProcessor.formatNode(namespaceJndiElement);
cleanupProcessor.cleanupNode(namespaceJndiElement);
legacyXmlElement.getParentNode().removeChild(legacyXmlElement);
}
finally {
if (model != null) {