code: protected String checkDTDKeyword(String exp)
          throws XMLStreamException
      {
          int i = 0;
          int len = exp.length();
          char c = ' ';
  
          for (; i < len; ++i) {
              if (mInputPtr < mInputEnd) {
                  c = mInputBuffer[mInputPtr++];
              } else {
                  c = dtdNextIfAvailable();
                  if (c == CHAR_NULL) { // end of block, fine
                      return exp.substring(0, i);
                  }
              }
              if (c != exp.charAt(i)) {
                  break;
              }
          }
  
          if (i == len) {
              // Got a match? Cool... except if identifier still continues...
              c = dtdNextIfAvailable();
              if (c == CHAR_NULL) { // EOB, fine
                  return null;
              }
              if (!isNameChar(c)) {
                  --mInputPtr; // to push it back
                  return null;
              }
          }
          StringBuilder sb = new StringBuilder(exp.substring(0, i));
          sb.append(c);
          while (true) {
              c = dtdNextIfAvailable();
              if (c == CHAR_NULL) { // EOB, fine
                  break;
              }
              if (!isNameChar(c) && c != ':') {
                  --mInputPtr; // to push it back
                  break;
              }
              sb.append(c);
          }
          return sb.toString();
      }
docs: Method called to verify whether input has specified keyword; if it
  has, returns null and points to char after the keyword; if not,
  returns whatever constitutes a keyword matched, for error
  reporting purposes.