private static String addMavenNamespace(String effectiveXml, boolean isPom) {
    SAXBuilder builder = new SAXBuilder();

    try {
      Document document = builder.build(new StringReader(effectiveXml));
      Element rootElement = document.getRootElement();

      // added namespaces
      Namespace pomNamespace = Namespace.getNamespace("", "http://maven.apache.org/POM/4.0.0");
      rootElement.setNamespace(pomNamespace);

      Namespace xsiNamespace = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
      rootElement.addNamespaceDeclaration(xsiNamespace);
      if (rootElement.getAttribute("schemaLocation", xsiNamespace) == null) {
        rootElement.setAttribute("schemaLocation", "http://maven.apache.org/POM/4.0.0 "
                                                   + (isPom ? POM_XSD_URL : SETTINGS_XSD_URL), xsiNamespace);
      }

      ElementFilter elementFilter = new ElementFilter(Namespace.getNamespace(""));
      for (Iterator<Element> i = rootElement.getDescendants(elementFilter); i.hasNext(); ) {
        Element e = i.next();
        e.setNamespace(pomNamespace);
      }

      addLineBreaks(document, pomNamespace);

      StringWriter w = new StringWriter();
      Format format = Format.getRawFormat();
      XMLOutputter out = new XMLOutputter(format);
      out.output(document.getRootElement(), w);

      return w.toString();
    }
    catch (JDOMException | IOException e) {
      return effectiveXml;
    }
  }
private static String addMavenNamespace(String effectiveXml, boolean isPom)