X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fxml%2Fcodec%2FXmlStreamUtils.java;h=c90d3e5d5664553a9ad73da745d201823d47ddc7;hp=0f93f43c566639641c32a3a1472d0c84ae8e513f;hb=1c9255fca204f4f7207d4fe3521fbfcdf087e10d;hpb=b5b204bafd8ee18692fc023cb2eae6e123369340 diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/xml/codec/XmlStreamUtils.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/xml/codec/XmlStreamUtils.java index 0f93f43c56..c90d3e5d56 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/xml/codec/XmlStreamUtils.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/xml/codec/XmlStreamUtils.java @@ -9,6 +9,12 @@ package org.opendaylight.controller.xml.codec; import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; +import java.net.URI; +import java.util.Map.Entry; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.AttributesContainer; import org.opendaylight.yangtools.yang.data.api.CompositeNode; @@ -29,13 +35,6 @@ import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefi import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; -import java.net.URI; -import java.util.Map.Entry; - /** * Utility class for bridging JAXP Stream and YANG Data APIs. Note that the definition of this class * by no means final and subject to change as more functionality is centralized here. @@ -136,15 +135,14 @@ public class XmlStreamUtils { */ public void writeElement(final XMLStreamWriter writer, final @Nonnull Node data, final SchemaNode schema) throws XMLStreamException { final QName qname = data.getNodeType(); - final String pfx = qname.getPrefix() != null ? qname.getPrefix() : ""; final String ns = qname.getNamespace() != null ? qname.getNamespace().toString() : ""; if (isEmptyElement(data)) { - writer.writeEmptyElement(pfx, qname.getLocalName(), ns); + writer.writeEmptyElement("", qname.getLocalName(), ns); return; } - writer.writeStartElement(pfx, qname.getLocalName(), ns); + writer.writeStartElement("", qname.getLocalName(), ns); if (data instanceof AttributesContainer && ((AttributesContainer) data).getAttributes() != null) { for (Entry attribute : ((AttributesContainer) data).getAttributes().entrySet()) { writer.writeAttribute(attribute.getKey().getNamespace().toString(), attribute.getKey().getLocalName(), attribute.getValue()); @@ -226,15 +224,9 @@ public class XmlStreamUtils { private static void write(final @Nonnull XMLStreamWriter writer, final @Nonnull IdentityrefTypeDefinition type, final @Nonnull Object value) throws XMLStreamException { if (value instanceof QName) { final QName qname = (QName) value; - final String prefix; - if (qname.getPrefix() != null && !qname.getPrefix().isEmpty()) { - prefix = qname.getPrefix(); - } else { - prefix = "x"; - } - writer.writeNamespace(prefix, qname.getNamespace().toString()); - writer.writeCharacters(prefix + ':' + qname.getLocalName()); + writer.writeNamespace("x", qname.getNamespace().toString()); + writer.writeCharacters("x:" + qname.getLocalName()); } else { if(LOG.isDebugEnabled()) { LOG.debug("Value of {}:{} is not a QName but {}", type.getQName().getNamespace(), type.getQName().getLocalName(), value.getClass());