[ONOS-6820] YTB with processed objects for resource id.
Change-Id: I5bbe0edf8c686c0beab684517845a131e4d1aadb
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModIdToRscIdConverter.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModIdToRscIdConverter.java
index a2991ed..74b4f96 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModIdToRscIdConverter.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/ModIdToRscIdConverter.java
@@ -25,6 +25,7 @@
import org.onosproject.yang.compiler.datamodel.YangRpc;
import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
import org.onosproject.yang.compiler.datamodel.YangSchemaNodeType;
+import org.onosproject.yang.compiler.datamodel.YangType;
import org.onosproject.yang.model.AtomicPath;
import org.onosproject.yang.model.ModelObjectId;
import org.onosproject.yang.model.MultiInstanceLeaf;
@@ -41,11 +42,12 @@
import static org.onosproject.yang.compiler.datamodel.YangSchemaNodeType.YANG_NON_DATA_NODE;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.nonEmpty;
import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCamelCase;
-import static org.onosproject.yang.runtime.impl.ModelConverterUtil.fetchPackage;
-import static org.onosproject.yang.runtime.impl.ModelConverterUtil.getAttributeOfObject;
import static org.onosproject.yang.runtime.RuntimeHelper.DEFAULT_CAPS;
import static org.onosproject.yang.runtime.RuntimeHelper.PERIOD;
import static org.onosproject.yang.runtime.RuntimeHelper.getCapitalCase;
+import static org.onosproject.yang.runtime.impl.ModelConverterUtil.fetchPackage;
+import static org.onosproject.yang.runtime.impl.ModelConverterUtil.getAttributeOfObject;
+import static org.onosproject.yang.runtime.impl.ModelConverterUtil.getObjFromType;
/**
* Converts model object identifier to resource identifier.
@@ -53,34 +55,30 @@
class ModIdToRscIdConverter {
/**
+ * Model registry.
+ */
+ private final DefaultYangModelRegistry reg;
+ /**
* Schema node with respect to the last atomic path in model object
* identifier. in case of leaf node as last atomic path last index node
* will be leaf's parent node.
*/
private YangSchemaNode lastIndexNode;
-
/**
* Flag to know if model object identifier contains leaf identifier.
*/
private boolean isMoIdWithLeaf;
-
/**
* Flag is true if rpc is added in branch point schema of resource
* identifier.
*/
private boolean isRpcAdded = true;
-
/**
* Flag is true if we have found module node using input/output packages.
*/
private boolean isInputOrOutput;
/**
- * Model registry.
- */
- private final DefaultYangModelRegistry reg;
-
- /**
* Creates an instance of converter.
*
* @param registry model registry
@@ -240,11 +238,12 @@
if (curNode instanceof YangList) {
YangList list = (YangList) curNode;
MultiInstanceNode mil = (MultiInstanceNode) path;
- Object keyObj = mil.key();
+ Object keysObj = mil.key();
Set<String> keys = list.getKeyLeaf();
for (String key : keys) {
+ Object obj = getKeyObject(keysObj, key, list);
builder.addKeyLeaf(key, list.getNameSpace()
- .getModuleNamespace(), getKeyValue(keyObj, key));
+ .getModuleNamespace(), obj);
}
}
} else {
@@ -264,13 +263,13 @@
ResourceId.Builder builder, AtomicPath path) {
//check leaf nodes in previous nodes.
String pkg = fetchPackage(path);
- YangSchemaNode curNode = fetchLeaf(preNode, pkg);
+ YangSchemaNode curNode = fetchLeaf(preNode, pkg, false);
if (curNode == null) {
if (preNode instanceof YangAugmentableNode) {
List<YangAugment> augments = ((YangAugmentableNode) preNode)
.getAugmentedInfoList();
for (YangAugment augment : augments) {
- curNode = fetchLeaf(augment, pkg);
+ curNode = fetchLeaf(augment, pkg, false);
if (curNode != null) {
break;
}
@@ -288,7 +287,9 @@
} else {
// leaf list should be added as leaf list branch point
// schema with its value added to it.
+ YangType<?> type = ((YangLeafList) curNode).getDataType();
Object val = ((MultiInstanceLeaf) path).value();
+ val = getObjFromType(preNode, path, curNode, "value", val, type);
builder.addLeafListBranchPoint(curNode.getName(), curNode
.getNameSpace().getModuleNamespace(), val);
}
@@ -384,24 +385,32 @@
return null;
}
- private YangSchemaNode fetchLeaf(YangSchemaNode node, String name) {
+ private YangSchemaNode fetchLeaf(YangSchemaNode node, String name,
+ boolean isSchemaName) {
YangLeavesHolder holder = (YangLeavesHolder) node;
List<YangLeaf> leaves = holder.getListOfLeaf();
+ String lName;
// check if the names is equal to any of the leaf/leaf-list nodes.
if (nonEmpty(leaves)) {
for (YangLeaf leaf : leaves) {
- if (leaf.getJavaAttributeName().toLowerCase()
- .equals(name)) {
+ lName = leaf.getName();
+ if (!isSchemaName) {
+ lName = leaf.getJavaAttributeName().toLowerCase();
+ }
+ if (lName.equals(name)) {
return leaf;
}
}
}
List<YangLeafList> leafLists = holder.getListOfLeafList();
if (nonEmpty(leafLists)) {
- for (YangLeafList leaf : leafLists) {
- if (leaf.getJavaAttributeName().toLowerCase()
- .equals(name)) {
- return leaf;
+ for (YangLeafList ll : leafLists) {
+ lName = ll.getName();
+ if (!isSchemaName) {
+ lName = ll.getJavaAttributeName().toLowerCase();
+ }
+ if (lName.equals(name)) {
+ return ll;
}
}
}
@@ -435,4 +444,39 @@
boolean isInputOrOutput() {
return isInputOrOutput;
}
+
+ /**
+ * Returns the key leaf's processed object to be present in the resource id.
+ *
+ * @param keysObj list of keys object
+ * @param key leaf key object
+ * @param list YANG list
+ * @return processed object
+ */
+ private Object getKeyObject(Object keysObj, String key, YangList list) {
+ Object keyObj = getKeyValue(keysObj, key);
+ YangSchemaNode leaf = fetchLeaf(list, key, true);
+
+ if (leaf == null) {
+ List<YangAugment> augment = list.getAugmentedInfoList();
+ for (YangAugment a : augment) {
+ leaf = fetchLeaf(a, key, true);
+ if (leaf != null) {
+ break;
+ }
+ }
+ }
+ if (leaf == null) {
+ throw new ModelConvertorException(
+ "The specified key " + key + " is not present in the " +
+ "YANG schema node.");
+ }
+ YangType<?> type;
+ if (leaf instanceof YangLeaf) {
+ type = ((YangLeaf) leaf).getDataType();
+ } else {
+ type = ((YangLeafList) leaf).getDataType();
+ }
+ return getObjFromType(list, keysObj, leaf, key, keyObj, type);
+ }
}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/L3vpnModelConverterTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/L3vpnModelConverterTest.java
index f1c69e8..9b1ff75 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/L3vpnModelConverterTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/L3vpnModelConverterTest.java
@@ -626,11 +626,8 @@
assertThat("site-id", is(sid.name()));
assertThat(NAME_SPACE_SVC, is(sid.namespace()));
- assertThat(true, is(keyLeaf.leafValue() instanceof SvcId));
- assertThat("site-keys", is(keyLeaf.leafValAsString()));
-
- SvcId id = (SvcId) keyLeaf.leafValue();
- assertThat("site-keys", is(id.string()));
+ assertThat(false, is(keyLeaf.leafValue() instanceof SvcId));
+ assertThat("site-keys", is(keyLeaf.leafValue()));
dataNodes = rscData.dataNodes();
assertThat(1, is(dataNodes.size()));
@@ -760,11 +757,8 @@
assertThat("site-id", is(sid.name()));
assertThat(NAME_SPACE_SVC, is(sid.namespace()));
- assertThat(true, is(keyLeaf.leafValue() instanceof SvcId));
- assertThat("site-keys", is(keyLeaf.leafValAsString()));
-
- SvcId id = (SvcId) keyLeaf.leafValue();
- assertThat("site-keys", is(id.string()));
+ assertThat(false, is(keyLeaf.leafValue() instanceof SvcId));
+ assertThat("site-keys", is(keyLeaf.leafValue()));
sid = keys.get(4).schemaId();
assertThat("site-network-accesses", is(sid.name()));
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YtbResourceIdTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YtbResourceIdTest.java
new file mode 100644
index 0000000..32b362c
--- /dev/null
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YtbResourceIdTest.java
@@ -0,0 +1,286 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.impl;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.Bitdef;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.DefaultType;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.DefaultVal;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.Id;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.Phy;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.Tdef1;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.TypeKeys;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.Vir;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.id.IdUnion;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.tdef1.Tdef1Union;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.type.DefaultCon1;
+import org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.type.Leaf1Union;
+import org.onosproject.yang.gen.v1.modulelistandkeyaugment.rev20160826.modulelistandkeyaugment.val.AugmentedSchVal;
+import org.onosproject.yang.model.DefaultModelObjectData.Builder;
+import org.onosproject.yang.model.KeyLeaf;
+import org.onosproject.yang.model.LeafIdentifier;
+import org.onosproject.yang.model.LeafListKey;
+import org.onosproject.yang.model.ListKey;
+import org.onosproject.yang.model.ModelObjectId;
+import org.onosproject.yang.model.NodeKey;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.SchemaId;
+
+import java.math.BigInteger;
+import java.util.Base64;
+import java.util.Iterator;
+import java.util.List;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.ModuleListAndKey.LeafIdentifier.LL1;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.ModuleListAndKey.LeafIdentifier.LL2;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.ModuleListAndKey.LeafIdentifier.LL3;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.ModuleListAndKey.LeafIdentifier.LL4;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.ModuleListAndKey.LeafIdentifier.LL5;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.ModuleListAndKey.LeafIdentifier.LL6;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.ModuleListAndKey.LeafIdentifier.LL7;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.ModuleListAndKey.LeafIdentifier.LL8;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.ModuleListAndKey.LeafIdentifier.LL9;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.Bitdef.fromString;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.Ll6Enum.ENUM1;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.type.Con1.LeafIdentifier.LL;
+import static org.onosproject.yang.gen.v1.modulelistandkey.rev20160826.modulelistandkey.type.Leaf6Enum.ENUM2;
+import static org.onosproject.yang.model.ModelObjectId.builder;
+
+/**
+ * Unit test cases for resource id conversion from model object id.
+ */
+public class YtbResourceIdTest {
+
+ private final TestYangSchemaNodeProvider schemaProvider = new
+ TestYangSchemaNodeProvider();
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+ private ResourceData rscData;
+ private DefaultDataTreeBuilder treeBuilder;
+ private ResourceId id;
+ private List<NodeKey> keys;
+ private SchemaId sid;
+ private ModelObjectId mid;
+ private Builder data;
+
+ /**
+ * Prior setup for each UT.
+ */
+ private void setUp() {
+ schemaProvider.processSchemaRegistry();
+ DefaultYangModelRegistry registry = schemaProvider.registry();
+ treeBuilder = new DefaultDataTreeBuilder(registry);
+ }
+
+ /**
+ * Processes and checks the conversion of model object id, which contains
+ * a list with many keys, to resource id.
+ */
+ @Test
+ public void processKeysInRid() {
+ setUp();
+ data = new Builder();
+ mid = buildMidWithKeys().build();
+ data.identifier(mid);
+ rscData = treeBuilder.getResourceData(data.build());
+ id = rscData.resourceId();
+ validateRidWithKeys(id);
+ }
+
+ /**
+ * Processes and checks the conversion of model object id, which contains
+ * a list with many keys, a container and ends with a leaf-list, to
+ * resource id.
+ */
+ @Test
+ public void processNodeAndLeafListInRid() {
+ setUp();
+ data = new Builder();
+ ModelObjectId.Builder builder = buildMidWithKeys();
+ Tdef1 tdef1 = new Tdef1(Tdef1Union.fromString("thousand"));
+ mid = builder.addChild(DefaultCon1.class).addChild(LL, tdef1).build();
+ data.identifier(mid);
+ rscData = treeBuilder.getResourceData(data.build());
+ id = rscData.resourceId();
+ LeafListKey key = (LeafListKey) id.nodeKeys().get(3);
+ assertThat(key.value(), is("thousand"));
+ }
+
+ /**
+ * Processes and checks the conversion of model object id, which contains
+ * a container and ends with an augmented leaf-list, to resource id.
+ */
+ @Test
+ public void processAugmentedLeafListRid() {
+ setUp();
+ data = new Builder();
+ mid = builder().addChild(DefaultVal.class)
+ .addChild(AugmentedSchVal.LeafIdentifier.LL, fromString("num"))
+ .build();
+ data.identifier(mid);
+ rscData = treeBuilder.getResourceData(data.build());
+ id = rscData.resourceId();
+ LeafListKey key = (LeafListKey) id.nodeKeys().get(2);
+ assertThat(key.value(), is("num"));
+ }
+
+ /**
+ * Processes and checks the conversion of model object id, which ends with
+ * a leaf-list, to resource id.
+ */
+ @Test
+ public void processLeafListInRid() {
+ LeafListKey key = buildRidForLeafList(LL1, (byte) 18);
+ assertThat(key.value(), is((byte) 18));
+
+ key = buildRidForLeafList(LL2, Vir.class);
+ assertThat(key.value(), is("vir"));
+
+ Tdef1 def1 = new Tdef1(Tdef1Union.fromString("hundred"));
+ key = buildRidForLeafList(LL3, def1);
+ assertThat(key.value(), is("hundred"));
+
+ key = buildRidForLeafList(LL4, Phy.class);
+ assertThat(key.value(), is("phy"));
+
+ key = buildRidForLeafList(LL5, "/1/2/3");
+ assertThat(key.value(), is("/1/2/3"));
+
+ key = buildRidForLeafList(LL6, ENUM1);
+ assertThat(key.value(), is("enum1"));
+
+ key = buildRidForLeafList(LL7, fromString("str"));
+ assertThat(key.value(), is("str"));
+
+ byte[] arr = Base64.getDecoder().decode("QXdnRQ==");
+ key = buildRidForLeafList(LL8, arr);
+ assertThat(key.value(), is("AwgE"));
+
+ Id id = new Id(IdUnion.fromString("true"));
+ key = buildRidForLeafList(LL9, id);
+ assertThat(key.value(), is("true"));
+ }
+
+ /**
+ * Builds resource id with the leaf identifier and the value.
+ *
+ * @param lId leaf identifier
+ * @param val value
+ * @return leaf list key
+ */
+ private LeafListKey buildRidForLeafList(LeafIdentifier lId, Object val) {
+ setUp();
+ data = new Builder();
+ mid = ModelObjectId.builder().addChild(lId, val).build();
+ data.identifier(mid);
+ rscData = treeBuilder.getResourceData(data.build());
+ id = rscData.resourceId();
+ keys = id.nodeKeys();
+ return (LeafListKey) keys.get(1);
+ }
+
+ /**
+ * Validates values in the list keys of the resource id.
+ *
+ * @param id resource id
+ */
+ private void validateRidWithKeys(ResourceId id) {
+ String nameSpace = "yms:test:ytb:tree:builder:for:list:having:list";
+ keys = id.nodeKeys();
+ assertThat(2, is(keys.size()));
+
+ sid = keys.get(0).schemaId();
+ assertThat("/", is(sid.name()));
+ assertThat(null, is(sid.namespace()));
+
+ sid = keys.get(1).schemaId();
+ assertThat("type", is(sid.name()));
+ assertThat(nameSpace, is(sid.namespace()));
+
+ ListKey listKey = (ListKey) keys.get(1);
+
+ Iterator<KeyLeaf> it = listKey.keyLeafs().iterator();
+ assertThat(9, is(listKey.keyLeafs().size()));
+
+ validateKeyLeaf(it.next(), "leaf1", nameSpace, (byte) 8);
+
+ validateKeyLeaf(it.next(), "leaf2", nameSpace, "vir");
+
+ validateKeyLeaf(it.next(), "leaf3", nameSpace,
+ new BigInteger("176889"));
+
+ validateKeyLeaf(it.next(), "leaf4", nameSpace, "phy");
+
+ validateKeyLeaf(it.next(), "leaf5", nameSpace, "/class");
+
+ validateKeyLeaf(it.next(), "leaf6", nameSpace, "enum2");
+
+ validateKeyLeaf(it.next(), "leaf7", nameSpace, "num");
+
+ validateKeyLeaf(it.next(), "leaf8", nameSpace, "11011");
+
+ //FIXME: Union under object provider.
+ validateKeyLeaf(it.next(), "leaf9", nameSpace, "true");
+ }
+
+ /**
+ * Builds model object id, containing list keys.
+ *
+ * @return model object id
+ */
+ private ModelObjectId.Builder buildMidWithKeys() {
+ Leaf1Union l1 = new Leaf1Union((byte) 8);
+ Tdef1Union tdef1Uni = new Tdef1Union(new BigInteger("176889"));
+ Tdef1 def1 = new Tdef1(tdef1Uni);
+ Bitdef def = fromString("num");
+ byte[] arr = Base64.getDecoder().decode("MTEwMTE=");
+ IdUnion idUni = new IdUnion(true);
+ Id id = new Id(idUni);
+ TypeKeys typeKeys = new TypeKeys();
+ typeKeys.leaf1(l1);
+ typeKeys.leaf2(Vir.class);
+ typeKeys.leaf3(def1);
+ typeKeys.leaf4(Phy.class);
+ typeKeys.leaf5("/class");
+ typeKeys.leaf6(ENUM2);
+ typeKeys.leaf7(def);
+ typeKeys.leaf8(arr);
+ typeKeys.leaf9(id);
+ return builder().addChild(DefaultType.class, typeKeys);
+ }
+
+ /**
+ * Validates the key leaf with the respective values.
+ *
+ * @param keyLeaf key leaf
+ * @param lName leaf name
+ * @param nameSpace name space
+ * @param value leaf-list value
+ */
+ private void validateKeyLeaf(KeyLeaf keyLeaf, String lName,
+ String nameSpace, Object value) {
+ sid = keyLeaf.leafSchema();
+ assertThat(lName, is(sid.name()));
+ assertThat(nameSpace, is(sid.namespace()));
+ assertThat(value, is(keyLeaf.leafValue()));
+ }
+}
diff --git a/runtime/src/test/resources/ytbTestYangFiles/AugmentModuleListAndKey.yang b/runtime/src/test/resources/ytbTestYangFiles/AugmentModuleListAndKey.yang
index 3056053..e144c99 100644
--- a/runtime/src/test/resources/ytbTestYangFiles/AugmentModuleListAndKey.yang
+++ b/runtime/src/test/resources/ytbTestYangFiles/AugmentModuleListAndKey.yang
@@ -15,4 +15,16 @@
}
}
}
+
+ augment "/sch:type" {
+ leaf leaf10 {
+ type int32;
+ }
+ }
+
+ augment "/sch:val" {
+ leaf-list ll {
+ type sch:bitdef;
+ }
+ }
}
\ No newline at end of file
diff --git a/runtime/src/test/resources/ytbTestYangFiles/ModuleAndListWithKey.yang b/runtime/src/test/resources/ytbTestYangFiles/ModuleAndListWithKey.yang
index 8810c6d..378a739 100644
--- a/runtime/src/test/resources/ytbTestYangFiles/ModuleAndListWithKey.yang
+++ b/runtime/src/test/resources/ytbTestYangFiles/ModuleAndListWithKey.yang
@@ -3,10 +3,167 @@
namespace "yms:test:ytb:tree:builder:for:list:having:list";
prefix "sch";
revision "2016-08-26";
+
list modKey {
key "types";
- leaf types {
- type int32;
+ leaf types {
+ type int32;
+ }
+ }
+
+ typedef tdef1 {
+ type union {
+ type uint64;
+ type enumeration {
+ enum ten {
+ value "10";
+ }
+ enum hundred {
+ value "100";
+ }
+ enum thousand {
+ value "1000";
}
}
+ }
+ }
+
+ typedef bitdef {
+ type bits {
+ bit str;
+ bit num;
+ }
+ }
+
+ typedef id {
+ type union {
+ type identityref {
+ base int;
+ }
+ type boolean;
+ }
+ }
+
+ identity int {
+ description "type value";
+ }
+
+ identity phy {
+ base int;
+ }
+
+ identity vir {
+ base int;
+ }
+
+ list type {
+ key "leaf1 leaf2 leaf3 leaf4 leaf5 leaf6 leaf7 leaf8 leaf9";
+
+ leaf leaf1 {
+ type union {
+ type int8;
+ type uint8;
+ }
+ }
+
+ leaf leaf2 {
+ type identityref {
+ base int;
+ }
+ }
+
+ leaf leaf3 {
+ type tdef1;
+ }
+
+ leaf leaf4 {
+ type leafref {
+ path "../leaf2";
+ }
+ }
+
+ leaf leaf5 {
+ type instance-identifier;
+ }
+
+ leaf leaf6 {
+ type enumeration {
+ enum enum1;
+ enum enum2;
+ }
+ }
+
+ leaf leaf7 {
+ type bitdef;
+ }
+
+ leaf leaf8 {
+ type binary;
+ }
+
+ leaf leaf9 {
+ type id;
+ }
+
+ container con1 {
+ leaf-list ll {
+ type tdef1;
+ }
+ }
+ }
+
+ leaf-list tri {
+ type identityref {
+ base int;
+ }
+ }
+
+ leaf-list ll1 {
+ type union {
+ type int8;
+ type uint8;
+ }
+ }
+
+ leaf-list ll2 {
+ type identityref {
+ base int;
+ }
+ }
+
+ leaf-list ll3 {
+ type tdef1;
+ }
+
+ leaf-list ll4 {
+ type leafref {
+ path "../ll2";
+ }
+ }
+
+ leaf-list ll5 {
+ type instance-identifier;
+ }
+
+ leaf-list ll6 {
+ type enumeration {
+ enum enum1;
+ enum enum2;
+ }
+ }
+
+ leaf-list ll7 {
+ type bitdef;
+ }
+
+ leaf-list ll8 {
+ type binary;
+ }
+
+ leaf-list ll9 {
+ type id;
+ }
+
+ container val {
+ }
}
\ No newline at end of file