code: private XPathFactory loadFromServicesFile(String uri, String resourceName, InputStream in) {
  
          if (debug) debugPrintln("Reading " + resourceName );
  
          BufferedReader rd;
          try {
              rd = new BufferedReader(new InputStreamReader(in, "UTF-8"), DEFAULT_LINE_LENGTH);
          } catch (java.io.UnsupportedEncodingException e) {
              rd = new BufferedReader(new InputStreamReader(in), DEFAULT_LINE_LENGTH);
          }
  
          String factoryClassName;
          XPathFactory resultFactory = null;
          // See spec for provider-configuration files: http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Provider%20Configuration%20File
          while (true) {
              try {
                  factoryClassName = rd.readLine();
              } catch (IOException x) {
                  // No provider found
                  break;
              }
              if (factoryClassName != null) {
                  // Ignore comments in the provider-configuration file
                  int hashIndex = factoryClassName.indexOf('#');
                  if (hashIndex != -1) {
                      factoryClassName = factoryClassName.substring(0, hashIndex);
                  }
  
                  // Ignore leading and trailing whitespace
                  factoryClassName = factoryClassName.trim();
  
                  // If there's no text left or if this was a blank line, go to the next one.
                  if (factoryClassName.length() == 0) {
                      continue;
                  }
  
                  try {
                      // Found the right XPathFactory if its isObjectModelSupported(String uri) method returns true.
                      XPathFactory foundFactory = createInstance(factoryClassName);
                      if (foundFactory.isObjectModelSupported(uri)) {
                          resultFactory = foundFactory;
                          break;
                      }
                  } catch (Exception ignored) {
                  }
              }
              else {
                  break;
              }
          }
  
          IoUtils.closeQuietly(rd);
  
          return resultFactory;
      }
docs: Searches for a XPathFactory for a given uri in a META-INF/services file.