[ONOS-7318] XML/JSON serializer impl for valueNamespace decoding

Change-Id: Ia02a92e6b02a5587ddb028ec6a034d58574c14ad
diff --git a/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DefaultJsonWalker.java b/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DefaultJsonWalker.java
index f106a3e..46a5b98 100644
--- a/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DefaultJsonWalker.java
+++ b/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DefaultJsonWalker.java
@@ -138,20 +138,31 @@
         }
     }
 
-    private void addDataNode(String fieldName, String value, DataNode.Type nodeType) {
+    private void addDataNode(String fieldName, String value, String valNamespace,
+                             DataNode.Type nodeType) {
         String nodeName = getLatterSegment(fieldName, COLON);
         String namespace = getPreSegment(fieldName, COLON);
+
         dataNodeBuilder = SerializerHelper.addDataNode(dataNodeBuilder,
                                                        nodeName, namespace,
-                                                       value, nodeType);
+                                                       value, valNamespace,
+                                                       nodeType);
     }
 
     private void addNoneLeafDataNode(String fieldName, DataNode.Type nodeType) {
-        addDataNode(fieldName, null, nodeType);
+        addDataNode(fieldName, null, null, nodeType);
     }
 
     private void addLeafDataNode(String fieldName, String value, DataNode.Type nodeType) {
-        addDataNode(fieldName, value, nodeType);
+        String valNamespace = null;
+        String actVal;
+        if (value != null) {
+            actVal = getLatterSegment(value, COLON);
+            valNamespace = getPreSegment(value, COLON);
+        } else {
+            actVal = value;
+        }
+        addDataNode(fieldName, actVal, valNamespace, nodeType);
     }
 
     private void addSingleInstanceNodeToDataTree(String fieldName) {
diff --git a/serializers/xml/src/main/java/org/onosproject/yang/serializers/xml/XmlSerializerListener.java b/serializers/xml/src/main/java/org/onosproject/yang/serializers/xml/XmlSerializerListener.java
index 76a44d9..eebc95c 100644
--- a/serializers/xml/src/main/java/org/onosproject/yang/serializers/xml/XmlSerializerListener.java
+++ b/serializers/xml/src/main/java/org/onosproject/yang/serializers/xml/XmlSerializerListener.java
@@ -27,6 +27,8 @@
 import static org.onosproject.yang.runtime.SerializerHelper.exitDataNode;
 import static org.onosproject.yang.runtime.SerializerHelper.getResourceId;
 import static org.onosproject.yang.serializers.utils.SerializersUtil.convertXmlAttributesToAnnotations;
+import static org.onosproject.yang.serializers.utils.SerializersUtil.getLatterSegment;
+import static org.onosproject.yang.serializers.utils.SerializersUtil.getPreSegment;
 import static org.onosproject.yang.serializers.xml.XmlNodeType.OBJECT_NODE;
 import static org.onosproject.yang.serializers.xml.XmlNodeType.TEXT_NODE;
 
@@ -35,6 +37,8 @@
  */
 class XmlSerializerListener implements XmlListener {
 
+    private static final String COLON = ":";
+
     /**
      * Data node builder.
      */
@@ -99,9 +103,22 @@
             }
         } else if (nodeType == TEXT_NODE) {
             if (dnBuilder != null) {
+                String valNamespace = null;
+                String actVal;
+                String valPrefix;
+                String value = element.getText();
+                if (value != null) {
+                    actVal = getLatterSegment(value, COLON);
+                    valPrefix = getPreSegment(value, COLON);
+                    if (valPrefix != null) {
+                        valNamespace = element.getNamespaceForPrefix(valPrefix).getURI();
+                    }
+                } else {
+                    actVal = value;
+                }
                 dnBuilder = addDataNode(dnBuilder, element.getName(),
                                         element.getNamespace().getURI(),
-                                        element.getText(), null);
+                                        actVal, valNamespace, null);
             }
         }
     }