+ TipProducingDataTree inMemoryDataTree == InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+ inMemoryDataTree.setSchemaContext(schemaContext);
+
+ // first data tree modification
+ MapEntryNode parentOrderedListEntryNode == Builders.mapEntryBuilder().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ parentOrderedListQName, parentKeyLeafQName, "pkval1"))
+ .withChild(Builders.leafBuilder().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifier(parentOrdinaryLeafQName))
+ .withValue("plfval1").build()).build();
+
+ OrderedMapNode parentOrderedListNode == Builders.orderedMapBuilder().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifier(parentOrderedListQName))
+ .withChild(parentOrderedListEntryNode).build();
+
+ ContainerNode parentContainerNode == Builders.containerBuilder().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifier(parentContainerQName))
+ .withChild(Builders.containerBuilder().withNodeIdentifier(
+ new NodeIdentifier(childContainerQName)).withChild(parentOrderedListNode).build()).build();
+
+ YangInstanceIdentifier path1 == YangInstanceIdentifier.of(parentContainerQName);
+
+ DataTreeModification treeModification == inMemoryDataTree.takeSnapshot().newModification();
+ treeModification.write(path1, parentContainerNode);
+
+ // second data tree modification
+ MapEntryNode childOrderedListEntryNode == Builders.mapEntryBuilder().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ childOrderedListQName, childKeyLeafQName, "chkval1"))
+ .withChild(Builders.leafBuilder().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifier(childOrdinaryLeafQName))
+ .withValue("chlfval1").build()).build();
+
+ OrderedMapNode childOrderedListNode == Builders.orderedMapBuilder().withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifier(childOrderedListQName))
+ .withChild(childOrderedListEntryNode).build();
+
+ ImmutableMap.Builder<QName, Object> builder == ImmutableMap.builder();
+ ImmutableMap<QName, Object> keys == builder.put(parentKeyLeafQName, "pkval1").build();
+
+ YangInstanceIdentifier path2 == YangInstanceIdentifier.of(parentContainerQName).node(childContainerQName)
+ .node(parentOrderedListQName).node(new NodeIdentifierWithPredicates(parentOrderedListQName, keys)).node(childOrderedListQName);
+
+ treeModification.write(path2, childOrderedListNode);
+ treeModification.ready();
+ inMemoryDataTree.validate(treeModification);
+ inMemoryDataTree.commit(inMemoryDataTree.prepare(treeModification));
+
+ DataTreeSnapshot snapshotAfterCommits == inMemoryDataTree.takeSnapshot();
+ Optional<NormalizedNode<?, ?>> readNode == snapshotAfterCommits.readNode(path1);
+ Optional<NormalizedNode<?, ?>> readNode2 == snapshotAfterCommits.readNode(path2);
+
+First comes the creation of in-memory data tree instance. The schema
+context (containing the model mentioned above) of this tree is set.
+After that, two normalized nodes are built. The first one consists of a
+parent container, a child container and a parent ordered list which
+contains a key leaf and an ordinary leaf. The second normalized node is
+a child ordered list that also contains a key leaf and an ordinary leaf.
+
+In order to add a child node to a node, method withChild() is used. It
+takes a NormalizedNode as argument. When creating a list entry,
+YangInstanceIdentifier.NodeIdentifierWithPredicates should be used as
+its identifier. Its arguments are the QName of the list, QName of the
+list key and the value of the key. Method withValue() specifies a value
+for the ordinary leaf in the list.
+
+Before writing a node to the data tree, a path (YangInstanceIdentifier)
+which determines its place in the data tree needs to be defined. The
+path of the first normalized node starts at the parent container. The
+path of the second normalized node points to the child ordered list
+contained in the parent ordered list entry specified by the key value
+"pkval1".
+
+Write operation is performed with both normalized nodes mentioned
+earlier. It consist of several steps. The first step is to instantiate a
+DataTreeModification object based on a DataTreeSnapshot.
+DataTreeSnapshot gives you the current state of the data tree. Then
+comes the write operation which writes a normalized node at the provided
+path in the data tree. After doing both write operations, method ready()
+has to be called, marking the modification as ready for application to
+the data tree. No further operations within the modification are
+allowed. The modification is then validated - checked whether it can be
+applied to the data tree. Finally we commit it to the data tree.
+
+Now you can access the written nodes. In order to do this, you have to
+create a new DataTreeSnapshot instance and call the method readNode()
+with path argument pointing to a particular node in the tree.
+
+Serialization / deserialization of YANG Data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If you want to deserialize YANG-modeled data which have the form of an
+XML document, you can use the XML parser found in the module
+yang-data-codec-xml. The parser walks through the XML document
+containing YANG-modeled data based on the provided SchemaContext and
+emits node events into a NormalizedNodeStreamWriter. The parser
+disallows multiple instances of the same element except for leaf-list
+and list entries. The parser also expects that the YANG-modeled data in
+the XML source are wrapped in a root element. Otherwise it will not work
+correctly.
+
+Here is an example of using the XML parser.