public static Document upgradeSchema(Document document, final String namespaceUri,
      final String schemaLocation, String schemaVersion)
      throws XPathExpressionException, ParserConfigurationException {
    if (StringUtils.isBlank(namespaceUri)) {
      throw new IllegalArgumentException("namespaceUri");
    }
    if (StringUtils.isBlank(schemaLocation)) {
      throw new IllegalArgumentException("schemaLocation");
    }
    if (StringUtils.isBlank(schemaVersion)) {
      throw new IllegalArgumentException("schemaVersion");
    }

    if (null != document.getDoctype()) {
      Node root = document.getDocumentElement();
      Document copiedDocument = getDocumentBuilder().newDocument();
      Node copiedRoot = copiedDocument.importNode(root, true);
      copiedDocument.appendChild(copiedRoot);
      document = copiedDocument;
    }

    final Element root = document.getDocumentElement();
    // since root is the cache element, then this oldNamespace will be the cache's namespaceURI
    String oldNamespaceUri = root.getNamespaceURI();

    // update the namespace
    if (!namespaceUri.equals(oldNamespaceUri)) {
      changeNamespace(root, oldNamespaceUri, namespaceUri);
    }

    // update the version
    root.setAttribute("version", schemaVersion);

    // update the schemaLocation attribute
    Node schemaLocationAttr = root.getAttributeNodeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI,
        W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION);
    String xsiPrefix = findPrefix(root, W3C_XML_SCHEMA_INSTANCE_NS_URI);
    Map<String, String> uriToLocation = new HashMap<>();
    if (schemaLocationAttr != null) {
      uriToLocation = buildSchemaLocationMap(schemaLocationAttr.getNodeValue());
    } else if (xsiPrefix == null) {
      // this namespace is not defined yet, define it
      xsiPrefix = W3C_XML_SCHEMA_INSTANCE_PREFIX;
      root.setAttribute("xmlns:" + xsiPrefix, W3C_XML_SCHEMA_INSTANCE_NS_URI);
    }

    uriToLocation.remove(oldNamespaceUri);
    uriToLocation.put(namespaceUri, schemaLocation);

    root.setAttributeNS(W3C_XML_SCHEMA_INSTANCE_NS_URI,
        xsiPrefix + ":" + W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION,
        getSchemaLocationValue(uriToLocation));

    return document;
  }
Upgrade the schema of a given Config XMl <code>document</code> to the given
<code>namespace</code>, <code>schemaLocation</code> and <code>version</code>.

@param document Config XML {@link Document} to upgrade.
@param namespaceUri Namespace URI to upgrade to.
@param schemaLocation Schema location to upgrade to.
@since GemFire 8.1
geode-core/src/main/java/org/apache/geode/management/internal/configuration/utils/XmlUtils.java