code: public String getNamespaceFromURI(String uri) {
          String breakChar = "/";
          if (uri.contains("#")) {
              breakChar = "#";
          } else {
              if (uri.substring(6).contains(":")) {
                  breakChar = ":";
              }
          }
  
          int pos = Math.min(uri.lastIndexOf(breakChar), uri.length());
          return uri.substring(0, pos + 1);
      }
docs: Gets namespace from uRI.
  
  @param uri the uri
  @return the namespace from uRI