@Override
  public List addExtraNamespacesToNamespaceResolver(
      Descriptor descriptor,
      CoreAbstractSession session,
      boolean allowOverride,
      boolean ignoreEqualResolvers) {
    if (equalNamespaceResolvers && !ignoreEqualResolvers) {
      return null;
    }

    org.eclipse.persistence.internal.oxm.NamespaceResolver descriptorNamespaceResolver =
        descriptor.getNamespaceResolver();
    if (null == descriptorNamespaceResolver
        || !descriptorNamespaceResolver.hasPrefixesToNamespaces()) {
      return null;
    }
    Map<String, String> prefixesToNamespaces =
        descriptorNamespaceResolver.getPrefixesToNamespaces();
    if (prefixesToNamespaces.size() == 0) {
      return null;
    }
    List returnList = new ArrayList(prefixesToNamespaces.size());
    org.eclipse.persistence.internal.oxm.NamespaceResolver marshalRecordNamespaceResolver =
        namespaceResolver;
    for (Entry<String, String> entry : prefixesToNamespaces.entrySet()) {

      // if isn't already on a parentadd namespace to this element
      String prefix = marshalRecordNamespaceResolver.resolveNamespaceURI(entry.getValue());

      if (prefix == null || prefix.length() == 0) {
        // if there is no prefix already declared for this uri in the nr add this one
        // unless that prefix is already bound to another namespace uri
        prefix = entry.getKey();
        if (hasCustomNamespaceMapper) {
          String newPrefix =
              getMarshaller()
                  .getNamespacePrefixMapper()
                  .getPreferredPrefix(entry.getValue(), prefix, true);
          if (newPrefix != null && !(newPrefix.length() == 0)) {
            prefix = newPrefix;
          }
        }
        String uri = marshalRecordNamespaceResolver.resolveNamespacePrefix(prefix);
        if (hasCustomNamespaceMapper || allowOverride || uri == null || uri.length() == 0) {
          // if this uri is unknown, the cutom mapper will return the preferred prefix for this uri
          marshalRecordNamespaceResolver.put(entry.getKey(), entry.getValue());
          returnList.add(new Namespace(prefix, entry.getValue()));
        }
      } else if (allowOverride) {
        // if overrides are allowed, add the prefix if the URI is different
        if (!prefix.equals(entry.getKey()) && !hasCustomNamespaceMapper) {
          // if prefix exists for uri but is different then add this
          // unless using a custom namespace prefix mapper. Then prefix is expected to be different
          marshalRecordNamespaceResolver.put(entry.getKey(), entry.getValue());
          returnList.add(new Namespace(entry.getKey(), entry.getValue()));
        }
      }
    }
    return returnList;
  }
 /**
  * INTERNAL: Private function to process or create an entry in the NamespaceResolver for the xsi
  * prefix.
  *
  * @param namespaceResolver
  * @return xsi prefix
  */
 protected String processNamespaceResolverForXSIPrefix(
     NamespaceResolver namespaceResolver, MarshalRecord marshalRecord) {
   String xsiPrefix;
   if (null == namespaceResolver) {
     // add new xsi entry into the properties map
     xsiPrefix = Constants.SCHEMA_INSTANCE_PREFIX;
     marshalRecord.namespaceDeclaration(
         xsiPrefix, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
   } else {
     // find an existing xsi entry in the map
     xsiPrefix =
         namespaceResolver.resolveNamespaceURI(
             javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
     if (null == xsiPrefix) {
       xsiPrefix = namespaceResolver.generatePrefix(Constants.SCHEMA_INSTANCE_PREFIX);
       marshalRecord.namespaceDeclaration(
           xsiPrefix, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
     }
   }
   return xsiPrefix;
 }