code: private int nextFromMultiDocState()
          throws XMLStreamException
      {
          if (mCurrToken == END_DOCUMENT) {
              /* Ok; this is the initial step; need to advance: need to parse
               * xml declaration if that was the cause, otherwise just clear
               * up values.
               */
              if (mSecondaryToken == START_DOCUMENT) {
                  handleMultiDocXmlDecl();
              } else { // Nah, DOCTYPE or start element... just need to clear decl info:
                  mDocXmlEncoding = null;
                  mDocXmlVersion = XmlConsts.XML_V_UNKNOWN;
                  mDocStandalone = DOC_STANDALONE_UNKNOWN;
              }
              return START_DOCUMENT;
          }
          if (mCurrToken == START_DOCUMENT) {
              mParseState = STATE_PROLOG; // yup, we are now officially in prolog again...
  
              // Had an xml decl (ie. "real" START_DOCUMENT event)
              if (mSecondaryToken == START_DOCUMENT) { // was a real xml decl
                  nextFromProlog(true);
                  return mCurrToken;
              }
              // Nah, start elem or DOCTYPE
              if (mSecondaryToken == START_ELEMENT) {
                  handleRootElem(getNextChar(SUFFIX_IN_ELEMENT));
                  return START_ELEMENT;
              }
              if (mSecondaryToken == DTD) {
                  mStDoctypeFound = true;
                  startDTD();
                  return DTD;
              }
          }
          throw new IllegalStateException("Internal error: unexpected state; current event "
                                          +tokenTypeDesc(mCurrToken)+", sec. state: "+tokenTypeDesc(mSecondaryToken));
      }
docs: Method called to get the next event when we are "multi-doc hack" mode,
  during which extra END_DOCUMENT/START_DOCUMENT events need to be
  returned.