Source:
static void parseEmbeddedElement(ObjectTypeAttributeDefinition attribute, XMLExtendedStreamReader reader, ModelNode op, String... additionalExpectedAttributes) throws XMLStreamException { AttributeDefinition[] valueTypes = attribute.getValueTypes(); Map<String, AttributeDefinition> attributes = new HashMap<>(); for (AttributeDefinition valueType : valueTypes) { if (attributes.put(valueType.getXmlName(), valueType) != null) { throw new IllegalStateException("Duplicate key"); } } Map<String, AttributeDefinition> attributeElements = new HashMap<>(); for (AttributeDefinition attributeDefinition : valueTypes) { if (attributeDefinition.getParser().isParseAsElement()) { if (attributeElements.put(attributeDefinition.getParser().getXmlName(attributeDefinition), attributeDefinition) != null) { throw new IllegalStateException("Duplicate key"); } } } for (int i = 0; i < reader.getAttributeCount(); i++) { String attributeName = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); if (attributes.containsKey(attributeName)) { AttributeDefinition def = attributes.get(attributeName); AttributeParser parser = def.getParser(); assert parser != null; parser.parseAndSetParameter(def, value, op, reader); } else if (Arrays.binarySearch(additionalExpectedAttributes, attributeName) < 0) { throw ParseUtils.unexpectedAttribute(reader, i, attributes.keySet()); } } if (!attributeElements.isEmpty()) { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { String attrName = reader.getLocalName(); if (attributeElements.containsKey(attrName)) { AttributeDefinition ad = attributeElements.get(reader.getLocalName()); ad.getParser().parseElement(ad, reader, op); } else { throw ParseUtils.unexpectedElement(reader, attributeElements.keySet()); } } } }

Target:
static void parseEmbeddedElement(ObjectTypeAttributeDefinition attribute, XMLExtendedStreamReader reader, ModelNode op, String... additionalExpectedAttributes) throws XMLStreamException { AttributeDefinition[] valueTypes = attribute.getValueTypes(); Map<String, AttributeDefinition> attributes = new HashMap<>(); for (AttributeDefinition valueType : valueTypes) { attributes.put(valueType.getXmlName(), valueType); } Map<String, AttributeDefinition> attributeElements = new HashMap<>(); for (AttributeDefinition attributeDefinition : valueTypes) { if (attributeDefinition.getParser().isParseAsElement()) { attributeElements.put(attributeDefinition.getParser().getXmlName(attributeDefinition), attributeDefinition); } } for (int i = 0; i < reader.getAttributeCount(); i++) { String attributeName = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); if (attributes.containsKey(attributeName)) { AttributeDefinition def = attributes.get(attributeName); AttributeParser parser = def.getParser(); assert parser != null; parser.parseAndSetParameter(def, value, op, reader); } else if (Arrays.binarySearch(additionalExpectedAttributes, attributeName) < 0) { throw ParseUtils.unexpectedAttribute(reader, i, attributes.keySet()); } } if (!attributeElements.isEmpty()) { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { String attrName = reader.getLocalName(); if (attributeElements.containsKey(attrName)) { AttributeDefinition ad = attributeElements.get(reader.getLocalName()); ad.getParser().parseElement(ad, reader, op); } else { throw ParseUtils.unexpectedElement(reader, attributeElements.keySet()); } } } }