// This is possible because JiBXDataSource is non destructive and implements the copy()
// method.
OMCloneOptions options = new OMCloneOptions();
options.setCopyOMDataSources(true);
boolean oldExpanded = element.isExpanded();
OMSourcedElement clone = (OMSourcedElement)element.clone(options);
if (element.isExpanded() != oldExpanded) {
throw new AxisFault("Ooops! Accidentally expanded the original OMSourcedElement; this is unexpected...");
}
// Force OMSourcedElement to get the element name via QNameAwareOMDataSource
log.info("Found OMSourcedElement: name=" + clone.getLocalName()
+ "; namespace=" + clone.getNamespaceURI()
+ "; prefix=" + clone.getPrefix());
// The OMSourcedElement should still be unexpanded
if (clone.isExpanded()) {
throw new AxisFault("OMSourcedElement unexpectedly expanded!");
}
// Now force expansion to let OMSourcedElement validate that the name is correct
clone.getFirstOMChild();
}