Merge "Bug 615: Removed xtend from Topology Manager"
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / toxml / SimpleAttributeWritingStrategy.java
index b327f8ebeff06733fd48ba7483d938b689ef477d..1b15171ca084b5409fa5992f7dc3f45300c80ea0 100644 (file)
@@ -13,6 +13,8 @@ import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import com.google.common.base.Optional;
+
 public class SimpleAttributeWritingStrategy implements AttributeWritingStrategy {
 
     private final Document document;
@@ -31,13 +33,15 @@ public class SimpleAttributeWritingStrategy implements AttributeWritingStrategy
     public void writeElement(Element parentElement, String namespace, Object value) {
         value = preprocess(value);
         Util.checkType(value, String.class);
-        Element innerNode = createElement(document, key, (String) value);
-        XmlUtil.addNamespaceAttr(innerNode, namespace);
+        Element innerNode = createElement(document, key, (String) value, Optional.of(namespace));
         parentElement.appendChild(innerNode);
     }
 
-    protected Element createElement(Document document, String key, String value) {
-        return XmlUtil.createTextElement(document, key, (String) value);
+    protected Element createElement(Document document, String key, String value, Optional<String> namespace) {
+        Element typeElement = XmlUtil.createElement(document, key, namespace);
+
+        typeElement.appendChild(document.createTextNode(value));
+        return typeElement;
     }
 
     protected Object preprocess(Object value) {