package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.toxml;
+import com.google.common.base.Optional;
+import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.ObjectNameAttributeMappingStrategy;
import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
-import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@Override
public void writeElement(Element parentElement, String namespace, Object value) {
Util.checkType(value, ObjectNameAttributeMappingStrategy.MappedDependency.class);
- Element innerNode = document.createElement(key);
- XmlUtil.addNamespaceAttr(innerNode, namespace);
+ Element innerNode = XmlUtil.createElement(document, key, Optional.of(namespace));
String moduleName = ((ObjectNameAttributeMappingStrategy.MappedDependency) value).getServiceName();
String refName = ((ObjectNameAttributeMappingStrategy.MappedDependency) value).getRefName();
String namespaceForType = ((ObjectNameAttributeMappingStrategy.MappedDependency) value).getNamespace();
- Element typeElement = XmlUtil.createPrefixedTextElement(document, XmlNetconfConstants.TYPE_KEY, XmlNetconfConstants.PREFIX,
- moduleName);
- XmlUtil.addPrefixedNamespaceAttr(typeElement, XmlNetconfConstants.PREFIX, namespaceForType);
+ Element typeElement = XmlUtil.createTextElementWithNamespacedContent(document, XmlNetconfConstants.TYPE_KEY, XmlNetconfConstants.PREFIX,
+ namespaceForType, moduleName);
+
innerNode.appendChild(typeElement);
- final Element nameElement = XmlUtil.createTextElement(document, XmlNetconfConstants.NAME_KEY, refName);
+ final Element nameElement = XmlUtil.createTextElement(document, XmlNetconfConstants.NAME_KEY, refName, Optional.<String>absent());
innerNode.appendChild(nameElement);
parentElement.appendChild(innerNode);