code: public static boolean isValidNmtoken(String nmtoken) {
      final int length = nmtoken.length();
      if (length == 0) {
        return false;
      }
      for (int i = 0; i < length; ++i) {
        char ch = nmtoken.charAt(i);
        if (!isName(ch)) {
          return false;
        }
      }
      return true;
    }
docs: Check to see if a string is a valid Nmtoken according to [7]
  in the XML 1.0 Recommendation
  
  @param nmtoken string to check
  @return true if nmtoken is a valid Nmtoken