String (final String uri) { // Manually do rule, since URIs can be null or empty if ((uri == null) || (uri.isEmpty())) { return null; } // Cannot start with a number final char first = uri.charAt(0); if (Character.isDigit(first)) { return "Namespace URIs cannot begin with a number"; } // Cannot start with a $ if (first == '$') { return "Namespace URIs cannot begin with a dollar sign ($)"; } // Cannot start with a - if (first == '-') { return "Namespace URIs cannot begin with a hyphen (-)"; } // Cannot start with space... if (isXMLWhitespace(first)) { return "Namespace URIs cannot begin with white-space"; } // If we got here, everything is OK return null; }