Source:
<code>public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (!(parentElement instanceof Event)) return; MessageEventDefinition eventDefinition = new MessageEventDefinition(); BpmnXMLUtil.addXMLLocation(eventDefinition, xtr); eventDefinition.setMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_MESSAGE_REF)); eventDefinition.setMessageExpression(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MESSAGE_EXPRESSION)); eventDefinition.setCorrelationKey(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MESSAGE_CORRELATION_KEY)); <START> List<ExtensionAttribute> attributes = new LinkedList<>(); <END> for(int i=0; i < xtr.getAttributeCount(); i++) { if(ACTIVITI_EXTENSIONS_NAMESPACE.equals(xtr.getAttributeNamespace(i))) { ExtensionAttribute attr = new ExtensionAttribute(ACTIVITI_EXTENSIONS_NAMESPACE, xtr.getAttributeLocalName(i)); attr.setValue(xtr.getAttributeValue(i)); attributes.add(attr); } } if(!attributes.isEmpty()) { eventDefinition.setAttributes(Collections.singletonMap(ACTIVITI_EXTENSIONS_PREFIX, attributes)); } if (!StringUtils.isEmpty(eventDefinition.getMessageRef())) { int indexOfP = eventDefinition.getMessageRef().indexOf(':'); if (indexOfP != -1) { String prefix = eventDefinition.getMessageRef().substring(0, indexOfP); String resolvedNamespace = model.getNamespace(prefix); String messageRef = eventDefinition.getMessageRef().substring(indexOfP + 1); if (resolvedNamespace == null) { messageRef = prefix + ":" + messageRef; } else if (!resolvedNamespace.equalsIgnoreCase(model.getTargetNamespace())) { messageRef = resolvedNamespace + ":" + messageRef; } eventDefinition.setMessageRef(messageRef); } else { eventDefinition.setMessageRef(eventDefinition.getMessageRef()); } } BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_MESSAGEDEFINITION, eventDefinition, xtr, model); ((Event) parentElement).getEventDefinitions().add(eventDefinition); }</code><technical_language>Do mind extract block line 48 57 a method. parseChildElement is long</technical_language>

Target:
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { if (!(parentElement instanceof Event)) return; MessageEventDefinition eventDefinition = new MessageEventDefinition(); BpmnXMLUtil.addXMLLocation(eventDefinition, xtr); eventDefinition.setMessageRef(xtr.getAttributeValue(null, ATTRIBUTE_MESSAGE_REF)); eventDefinition.setMessageExpression(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MESSAGE_EXPRESSION)); eventDefinition.setCorrelationKey(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MESSAGE_CORRELATION_KEY)); List<ExtensionAttribute> attributes = parseExtensionAttributes(xtr, parentElement, model); if(!attributes.isEmpty()) { eventDefinition.setAttributes(Collections.singletonMap(ACTIVITI_EXTENSIONS_PREFIX, attributes)); } if (!StringUtils.isEmpty(eventDefinition.getMessageRef())) { int indexOfP = eventDefinition.getMessageRef().indexOf(':'); if (indexOfP != -1) { String prefix = eventDefinition.getMessageRef().substring(0, indexOfP); String resolvedNamespace = model.getNamespace(prefix); String messageRef = eventDefinition.getMessageRef().substring(indexOfP + 1); if (resolvedNamespace == null) { messageRef = prefix + ":" + messageRef; } else if (!resolvedNamespace.equalsIgnoreCase(model.getTargetNamespace())) { messageRef = resolvedNamespace + ":" + messageRef; } eventDefinition.setMessageRef(messageRef); } else { eventDefinition.setMessageRef(eventDefinition.getMessageRef()); } } BpmnXMLUtil.parseChildElements(ELEMENT_EVENT_MESSAGEDEFINITION, eventDefinition, xtr, model); ((Event) parentElement).getEventDefinitions().add(eventDefinition); }