try {
// get a copy of the message for the processing, if the continueParent is set to true
// this original message can go in further mediations and hence we should not change
// the original message context
SOAPEnvelope envelope = MessageHelper.cloneSOAPEnvelope(synCtx.getEnvelope());
// get the iteration elements and iterate through the list,
// this call will also detach all the iteration elements
List splitElements = EIPUtils.getDetachedMatchingElements(envelope, expression);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Splitting with XPath : " + expression + " resulted in " +
splitElements.size() + " elements");
}
// if not preservePayload remove all the child elements
if (!preservePayload && envelope.getBody() != null) {
for (Iterator itr = envelope.getBody().getChildren(); itr.hasNext();) {
((OMNode) itr.next()).detach();
}
}
int msgCount = splitElements.size();