String (final String name) { // Check basic XML name rules first // Cannot be empty or null if (name == null) { return "XML names cannot be null"; } //final int len = name.length(); if (name.isEmpty()) { return "XML names cannot be empty"; } // Cannot start with a number if ((byte)0 == (CHARFLAGS[name.charAt(0)] & MASKXMLSTARTCHAR)) { return "XML name '" + name + "' cannot begin with the character \"" + name.charAt(0) + "\""; } // Ensure legal content for non-first chars // also check char 0 to catch colon char ':' for (int i = name.length() - 1; i >= 1; i--) { if ((byte)0 == (byte)(CHARFLAGS[name.charAt(i)] & MASKXMLNAMECHAR)) { return "XML name '" + name + "' cannot contain the character \"" + name.charAt(i) + "\""; } } // If we got here, everything is OK return null; }