@Override
 public String getNamespaceURI(String prefix) {
   if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
     if (defaultNamespaceURI == null) return XMLConstants.NULL_NS_URI;
     else return defaultNamespaceURI;
   } else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) {
     return XMLConstants.XML_NS_URI;
   } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) {
     return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
   } else if (prefix == null) {
     throw new IllegalArgumentException("Null prefix not allowed");
   } else {
     String uri = idNamespacesMap.get(prefix);
     if (uri == null) return XMLConstants.NULL_NS_URI;
     else return uri;
   }
 }
 @Override
 protected void writeAttr(String prefix, String localName, String namespaceURI, String value)
     throws XMLStreamException {
   String name =
       XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)
           ? localName
           : prefix + namespaceSeparator + localName;
   try {
     if (!getScope().getInfo().startObjectWritten) {
       target.startObject();
       getScope().getInfo().startObjectWritten = true;
     }
     target.name('@' + name);
     target.value(value);
   } catch (IOException e) {
     throw new XMLStreamException("Cannot write attribute: " + name, e);
   }
 }
 @Override
 protected void writeNsDecl(String prefix, String namespaceURI) throws XMLStreamException {
   if (namespaceDeclarations) {
     try {
       if (!getScope().getInfo().startObjectWritten) {
         target.startObject();
         getScope().getInfo().startObjectWritten = true;
       }
       if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
         target.name('@' + XMLConstants.XMLNS_ATTRIBUTE);
       } else {
         target.name('@' + XMLConstants.XMLNS_ATTRIBUTE + namespaceSeparator + prefix);
       }
       target.value(namespaceURI);
     } catch (IOException e) {
       throw new XMLStreamException("Cannot write namespace declaration: " + namespaceURI, e);
     }
   }
 }
 private String getFieldName(String prefix, String localName) {
   return XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)
       ? localName
       : prefix + namespaceSeparator + localName;
 }