code: private void readSpaceSecondary(boolean prologWS)
          throws XMLStreamException
      {
          /* Let's not bother optimizing input. However, we can easily optimize
           * output, since it's easy to do, yet has more effect on performance
           * than localizing input variables.
           */
          char[] outBuf = mTextBuffer.getCurrentSegment();
          int outPtr = mTextBuffer.getCurrentSegmentSize();
  
          while (true) {
              if (mInputPtr >= mInputEnd) {
                  /* 07-Oct-2005, TSa: Let's not throw an exception yet --
                   *   can return SPACE, and let exception be thrown
                   *   when trying to fetch next event.
                   */
                  if (!loadMore()) {
                      break;
                  }
              }
              char c = mInputBuffer[mInputPtr];
              if (c > CHAR_SPACE) { // end of WS?
                  break;
              }
              ++mInputPtr;
              if (c == '\n') {
                  markLF();
              } else if (c == '\r') {
                  if (skipCRLF(c)) {
                      if (!mNormalizeLFs) {
                          // Special handling, to output 2 chars at a time:
                          outBuf[outPtr++] = c;
                          if (outPtr >= outBuf.length) { // need more room?
                              outBuf = mTextBuffer.finishCurrentSegment();
                              outPtr = 0;
                          }
                      }
                      c = '\n';
                  } else if (mNormalizeLFs) {
                      c = '\n'; // For Mac text
                  }
              } else if (c != CHAR_SPACE && c != '\t') {
                  throwInvalidSpace(c);
              }
                  
              // Ok, let's add char to output:
              outBuf[outPtr++] = c;
  
              // Need more room?
              if (outPtr >= outBuf.length) {
                  outBuf = mTextBuffer.finishCurrentSegment();
                  outPtr = 0;
              }
          }
          mTextBuffer.setCurrentLength(outPtr);
      }
docs: This is very similar to readSecondaryText(); called when we need
  to read in rest of (ignorable) white space segment.
  
  @param prologWS True if the ignorable white space is within prolog
  (or epilog); false if it's within xml tree.