code: public static Map<String, String> getSchemaLocations(Document doc)
      {
          Set<String> namespaces = new HashSet<>();
          namespaces.addAll(LocationAwareXmlReader.getNamespaces(doc));
  
          String schemaLocation;
          try
          {
              schemaLocation = XmlUtil.xpathExtract(doc, "//@xsi:schemaLocation", objs);
          }
          catch (MarshallingException e)
          {
              throw new RuntimeException("Exception extracting xpath.", e);
          }
  
          Map<String, String> result = new HashMap<>();
          if (StringUtils.isNotBlank(schemaLocation))
          {
              schemaLocation = StringUtils.trim(schemaLocation);
              String[] locations = schemaLocation.split("\\s+");
              for (int i = 0, j = locations.length - 1; i < j; i++)
              {
                  if (namespaces.contains(locations[i]))
                  {
                      result.put(locations[i], locations[i + 1]);
                  }
              }
          }
  
          for (String r : result.keySet())
          {
              namespaces.remove(r);
          }
  
          // if there are namespaces without namespace locations, load here.
          if (namespaces.size() > 0)
          {
              for (String namespace : namespaces)
              {
                  result.put(namespace, null);
              }
          }
  
          return result;
      }
docs: Returns the names and locations defined in this {@link Document}.