- Map<QName, ChoiceNode> mappedChoiceChildNodes = mapChildElementsFromChoices(schema);
- LinkedListMultimap<ChoiceNode, E> choicesToElements = LinkedListMultimap.create();
+ Map<QName, ChoiceSchemaNode> mappedChoiceChildNodes = mapChildElementsFromChoices(schema);
+ LinkedListMultimap<ChoiceSchemaNode, E> choicesToElements = LinkedListMultimap.create();
+
+ Map<QName, String> attributes = getAttributes(elements.iterator().next());
+ if (containerBuilder instanceof AttributesBuilder) {
+ final int size = Iterables.size(elements);
+ Preconditions.checkArgument(size == 1, "Unexpected number of elements: %s, should be 1 for: %s",
+ size, schema);
+ ((AttributesBuilder<?>) containerBuilder).withAttributes(attributes);
+ }
+
+ //parse keys first
+ if (schema instanceof ListSchemaNode) {
+ for (QName qname : ((ListSchemaNode) schema).getKeyDefinition()) {
+ if(mappedChildElements.get(qname.withoutRevision()).isEmpty()) {
+ continue;
+ }
+
+ DataSchemaNode childSchema = getSchemaForChild(schema, qname);
+ List<E> childrenForQName = mappedChildElements.removeAll(qname.withoutRevision());
+
+
+ DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> optionalChildNode = getDispatcher()
+ .dispatchChildElement(childSchema, childrenForQName);
+ if (optionalChildNode != null) {
+ containerBuilder.withChild(optionalChildNode);
+ }
+ }
+ }
+
+ //stage attribues for strategy before going deeper in the recursion
+ buildingStrategy.prepareAttributes(attributes, containerBuilder);