code: private final ProfileDisablingMechanism limitGrammars()
  			throws EXIException, IOException {
  		ProfileDisablingMechanism retVal = ProfileDisablingMechanism.NONE;
  
  		Grammar currGrammar = getCurrentGrammar();
  
  		if (limitGrammarLearning && grammar.isSchemaInformed()
  				&& !currGrammar.isSchemaInformed()) {
  
  			// number of built-in grammars reached
  			if (maxBuiltInElementGrammars != -1) {
  				int csize = runtimeGlobalElements.size();
  				if (csize > maxBuiltInElementGrammars) {
  					if (currGrammar.getNumberOfEvents() == 0) {
  						// new grammar that hits bound
  						retVal = ProfileDisablingMechanism.XSI_TYPE;
  					} else if (isBuiltInStartTagGrammarWithAtXsiTypeOnly(currGrammar)) {
  						// previous type cast
  						retVal = ProfileDisablingMechanism.XSI_TYPE;
  					}
  				}
  			}
  
  			// number of productions reached?
  			if (this.maxBuiltInProductions != -1
  					&& retVal == ProfileDisablingMechanism.NONE
  					&& learnedProductions >= this.maxBuiltInProductions) {
  				// bound reached
  				if (this.lastEvent == EventType.START_ELEMENT
  						|| this.lastEvent == EventType.NAMESPACE_DECLARATION) {
  					// First mean possible: Insert xsi:type
  					retVal = ProfileDisablingMechanism.XSI_TYPE;
  				} else {
  					// Only 2nd mean possible: use ghost productions
  					retVal = ProfileDisablingMechanism.GHOST_PRODUCTION;
  					currGrammar.stopLearning();
  				}
  			}
  
  		}
  
  		return retVal;
  	}
docs: Note: returns ACTION