Program: 75361
Project: 75361
Buggy source:
/** 
 * Start an element. This is called at the beginning of each XML element.  By the time it is called, all of the attributes for the element will already have been reported using the attribute() method.  Unrecognized elements are ignored.
 * @param elementName The element type name.
 * @exception XmlException If the element produces an errorin constructing the model.
 */
public void startElement(String elementName) throws XmlException {
  try {
    if (_skipElement <= 0) {
      if (_configureNesting > 0 || _docNesting > 0) {
        if (elementName.equals("String_Node_Str")) {
          _configureNesting++;
        }
 else         if (elementName.equals("String_Node_Str")) {
          _docNesting++;
        }
        _currentCharData.append(_getCurrentElement(elementName));
        _attributes.clear();
        _attributeNameList.clear();
        return;
      }
    }
    if (_skipRendition) {
      return;
    }
    if (_undoEnabled && _isUndoableElement(elementName)) {
      boolean childNodesUndoable=true;
      if (_undoContext != null) {
        _undoContexts.push(_undoContext);
        childNodesUndoable=_undoContext.hasUndoableChildren();
      }
      _undoContext=new UndoContext(childNodesUndoable);
      if (_undoDebug) {
        System.out.println("String_Node_Str" + elementName);
      }
    }
    if (_skipElement > 0) {
      if (elementName.equals(_skipElementName)) {
        if (_skipElementIsNew) {
          _skipElementIsNew=false;
        }
 else {
          _skipElement++;
        }
      }
      return;
    }
    if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      String source=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      ComponentEntity previous=_searchForEntity(entityName);
      boolean existedAlready=false;
      if (previous != null) {
        existedAlready=true;
      }
      NamedObj newEntity=_createEntity(className,entityName,source);
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
      }
      _linkRequests=new LinkedList();
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=newEntity.toplevel();
        _toplevel.setDeferChangeRequests(true);
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      if (!existedAlready) {
        ((Prototype)newEntity).setClassDefinition(true);
        NamedObj.MoMLInfo info=newEntity.getMoMLInfo();
        info.className=newEntity.getFullName();
        info.superclass=className;
      }
 else {
        if (!previous.isClassDefinition()) {
          previous.setClassDefinition(true);
          NamedObj.MoMLInfo info=previous.getMoMLInfo();
          info.superclass=info.className;
          info.className=previous.getFullName();
        }
      }
      _current=newEntity;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled && _undoContext.isUndoable()) {
        if (existedAlready) {
          if (previous.isClassDefinition()) {
            _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
            _undoContext.appendClosingUndoMoML("String_Node_Str");
          }
 else {
            _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
            _undoContext.appendClosingUndoMoML("String_Node_Str");
          }
          _undoContext.setChildrenUndoable(true);
        }
 else {
          _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      _checkClass(_current,Configurable.class,"String_Node_Str" + "String_Node_Str" + _current);
      _configureSource=(String)_attributes.get("String_Node_Str");
      _currentCharData=new StringBuffer();
      _configureNesting++;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      NamedObj deletedEntity=_deleteEntity(entityName);
      if (_current != null) {
        _pushContext();
      }
      _current=deletedEntity;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled && _undoContext.isUndoable()) {
        _undoContext.setChildrenUndoable(false);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      NamedObj deletedPort=_deletePort(portName,entityName);
      if (_current != null) {
        _pushContext();
      }
      _current=deletedPort;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled && _undoContext.isUndoable()) {
        _undoContext.setChildrenUndoable(false);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String propName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propName,"String_Node_Str");
      NamedObj deletedProp=_deleteProperty(propName);
      if (_current != null) {
        _pushContext();
      }
      _current=deletedProp;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled && _undoContext.isUndoable()) {
        _undoContext.appendUndoMoML(deletedProp.exportMoML());
        _undoContext.setChildrenUndoable(false);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      NamedObj deletedRelation=_deleteRelation(relationName);
      if (_current != null) {
        _pushContext();
      }
      _current=deletedRelation;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled && _undoContext.isUndoable()) {
        _undoContext.setChildrenUndoable(false);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      String dirName=(String)_attributes.get("String_Node_Str");
      _checkForNull(dirName,"String_Node_Str");
      _checkClass(_current,CompositeActor.class,"String_Node_Str" + "String_Node_Str" + _current);
      Object[] arguments=new Object[2];
      arguments[0]=_current;
      arguments[1]=dirName;
      _pushContext();
      Class newClass=Class.forName(className,true,_classLoader);
      _current=_createInstance(newClass,arguments);
      _namespace=_DEFAULT_NAMESPACE;
    }
 else     if (elementName.equals("String_Node_Str")) {
      _currentDocName=(String)_attributes.get("String_Node_Str");
      _currentCharData=new StringBuffer();
      _docNesting++;
    }
 else     if (elementName.equals("String_Node_Str") || elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      String source=(String)_attributes.get("String_Node_Str");
      ComponentEntity previous=_searchForEntity(entityName);
      boolean existedAlready=false;
      if (previous != null) {
        existedAlready=true;
      }
      NamedObj newEntity=_createEntity(className,entityName,source);
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
      }
      _linkRequests=new LinkedList();
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=newEntity.toplevel();
        _toplevel.setDeferChangeRequests(true);
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      _current=newEntity;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled && _undoContext.isUndoable()) {
        if (existedAlready) {
          _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
          _undoContext.appendClosingUndoMoML("String_Node_Str");
          _undoContext.setChildrenUndoable(true);
        }
 else {
          _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String groupName=(String)_attributes.get("String_Node_Str");
      if (groupName != null) {
        _namespaces.push(_namespace);
        _namespaceTranslations.push(_namespaceTranslationTable);
        if (groupName.equals("String_Node_Str")) {
          _namespace=_AUTO_NAMESPACE;
          _namespaceTranslationTable=new HashMap();
        }
 else {
          _namespace=groupName;
        }
      }
 else {
        _namespaces.push(_DEFAULT_NAMESPACE);
        _namespaceTranslations.push(_namespaceTranslationTable);
        _namespace=_DEFAULT_NAMESPACE;
      }
      if (_undoEnabled && _undoContext.isUndoable()) {
        _undoContext.appendUndoMoML("String_Node_Str");
        _undoContext.appendClosingUndoMoML("String_Node_Str");
        _undoContext.setChildrenUndoable(true);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String source=(String)_attributes.get("String_Node_Str");
      _checkForNull(source,"String_Node_Str");
      boolean skip=false;
      if (inputFileNamesToSkip != null) {
        Iterator inputFileNames=inputFileNamesToSkip.iterator();
        while (inputFileNames.hasNext()) {
          String inputFileName=(String)inputFileNames.next();
          if (source.endsWith(inputFileName)) {
            skip=true;
            break;
          }
        }
      }
      if (!skip) {
        MoMLParser newParser=new MoMLParser(_workspace,_classLoader);
        newParser.setContext(_current);
        newParser._propagator=_propagator;
        _parse(newParser,_base,source);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      String insertAtSpec=(String)_attributes.get("String_Node_Str");
      String insertInsideAtSpec=(String)_attributes.get("String_Node_Str");
      LinkRequest request=new LinkRequest(portName,relationName,insertAtSpec,insertInsideAtSpec);
      if (_linkRequests != null) {
        _linkRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      _checkClass(_current,Entity.class,"String_Node_Str" + "String_Node_Str" + _current);
      Entity container=(Entity)_current;
      Class newClass=null;
      if (className != null && !className.trim().equals("String_Node_Str")) {
        newClass=Class.forName(className,true,_classLoader);
      }
      Port port=container.getPort(portName);
      boolean alreadyExisted=(port != null);
      if (port != null) {
        if (newClass != null) {
          _checkClass(port,newClass,"String_Node_Str" + portName + "String_Node_Str"+ className);
        }
      }
 else {
        if (newClass == null) {
          port=container.newPort(portName);
        }
 else {
          Object[] arguments=new Object[2];
          arguments[0]=container;
          arguments[1]=portName;
          port=(Port)_createInstance(newClass,arguments);
        }
      }
      _pushContext();
      _current=port;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled && _undoContext.isUndoable()) {
        if (alreadyExisted) {
          _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str");
          if (className != null) {
            _undoContext.appendUndoMoML("String_Node_Str" + className + "String_Node_Str");
          }
          _undoContext.appendUndoMoML("String_Node_Str");
          _undoContext.appendClosingUndoMoML("String_Node_Str");
          _undoContext.setChildrenUndoable(true);
        }
 else {
          _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
      }
      if (port instanceof IOPort) {
        String direction=(String)_attributes.get("String_Node_Str");
        if (direction != null) {
          IOPort ioport=(IOPort)port;
          boolean isOutput=direction.equals("String_Node_Str") || direction.equals("String_Node_Str");
          boolean isInput=direction.equals("String_Node_Str") || direction.equals("String_Node_Str");
          if (alreadyExisted && ioport.isClassElement() && (_propagator == null)) {
            if (ioport.isInput() != isInput || ioport.isOutput() != isOutput) {
              throw new IllegalActionException(ioport,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
            }
          }
          ioport.setOutput(isOutput);
          ioport.setInput(isInput);
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String propertyName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propertyName,"String_Node_Str");
      String value=(String)_attributes.get("String_Node_Str");
      _handlePropertyElement(className,propertyName,value);
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      CompositeEntity container=(CompositeEntity)_current;
      Class newClass=null;
      if (className != null) {
        newClass=Class.forName(className,true,_classLoader);
      }
      Relation relation=container.getRelation(relationName);
      boolean alreadyExisted=(relation != null);
      if (relation == null) {
        NamedObj newRelation=null;
        _pushContext();
        if (newClass == null) {
          newRelation=container.newRelation(relationName);
        }
 else {
          Object[] arguments=new Object[2];
          arguments[0]=(CompositeEntity)_current;
          arguments[1]=relationName;
          newRelation=_createInstance(newClass,arguments);
        }
        _namespace=_DEFAULT_NAMESPACE;
        _current=newRelation;
      }
 else {
        if (newClass != null) {
          _checkClass(relation,newClass,"String_Node_Str" + relationName + "String_Node_Str"+ className);
        }
        _pushContext();
        _current=relation;
        _namespace=_DEFAULT_NAMESPACE;
      }
      if (_undoEnabled && _undoContext.isUndoable()) {
        if (alreadyExisted) {
          _undoContext.appendUndoMoML("String_Node_Str" + relationName + "String_Node_Str");
          if (className != null) {
            _undoContext.appendUndoMoML("String_Node_Str" + className + "String_Node_Str");
          }
          _undoContext.appendUndoMoML("String_Node_Str");
          _undoContext.appendClosingUndoMoML("String_Node_Str");
          _undoContext.setChildrenUndoable(true);
        }
 else {
          _undoContext.appendUndoMoML("String_Node_Str" + relationName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String newName=(String)_attributes.get("String_Node_Str");
      _checkForNull(newName,"String_Node_Str");
      if (_current != null) {
        String oldName=_current.getName();
        if (!oldName.equals(newName) && _current.isClassElement() && (_propagator == null)) {
          throw new IllegalActionException(_current,"String_Node_Str" + newName + "String_Node_Str");
        }
        _current.setName(newName);
        if (_undoEnabled && _undoContext.isUndoable()) {
          try {
            UndoContext parentContext=(UndoContext)_undoContexts.peek();
            parentContext.applyRename(newName);
            _undoContext.appendUndoMoML("String_Node_Str" + oldName + "String_Node_Str");
            _undoContext.setChildrenUndoable(false);
          }
 catch (          Exception e) {
          }
        }
        if ((_current instanceof Prototype) && ((Prototype)_current).isClassDefinition()) {
          List deferredFrom=((Prototype)_current).getDeferredFrom();
          if (deferredFrom != null) {
            Iterator deferrers=deferredFrom.iterator();
            while (deferrers.hasNext()) {
              WeakReference reference=(WeakReference)deferrers.next();
              Prototype deferrer=(Prototype)reference.get();
              if (deferrer != null) {
                String replacementName=newName;
                if (deferrer.isClassDefinition()) {
                  if (deferrer.getMoMLInfo().superclass.startsWith("String_Node_Str")) {
                    replacementName=_current.getFullName();
                  }
                  deferrer.getMoMLInfo().superclass=replacementName;
                }
 else {
                  if (deferrer.getMoMLInfo().className.startsWith("String_Node_Str")) {
                    replacementName=_current.getFullName();
                  }
                  deferrer.getMoMLInfo().className=replacementName;
                }
              }
            }
          }
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      _skipRendition=true;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      String indexSpec=(String)_attributes.get("String_Node_Str");
      String insideIndexSpec=(String)_attributes.get("String_Node_Str");
      UnlinkRequest request=new UnlinkRequest(portName,relationName,indexSpec,insideIndexSpec);
      if (_linkRequests != null) {
        _linkRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String vertexName=(String)_attributes.get("String_Node_Str");
      _checkForNull(vertexName,"String_Node_Str");
      _checkClass(_current,Relation.class,"String_Node_Str" + "String_Node_Str" + _current);
      Vertex previous=(Vertex)_current.getAttribute(vertexName);
      String previousValue=null;
      if (previous != null) {
        previousValue=previous.getExpression();
      }
      Vertex vertex=new Vertex((Relation)_current,vertexName);
      String value=(String)_attributes.get("String_Node_Str");
      if (value != null) {
        vertex.setExpression(value);
        _paramsToParse.add(vertex);
      }
      _pushContext();
      _current=vertex;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled && _undoContext.isUndoable()) {
        _undoContext.appendUndoMoML("String_Node_Str" + vertexName + "String_Node_Str");
        if (previousValue != null) {
          _undoContext.appendUndoMoML("String_Node_Str" + previousValue + "String_Node_Str");
        }
        _undoContext.appendUndoMoML("String_Node_Str");
        _undoContext.setChildrenUndoable(true);
        _undoContext.appendClosingUndoMoML("String_Node_Str");
      }
    }
 else {
      if (_unrecognized == null) {
        _unrecognized=new LinkedList();
      }
      _unrecognized.add(elementName);
    }
  }
 catch (  InvocationTargetException ex) {
    if (_handler != null) {
      int reply=_handler.handleError(_getCurrentElement(elementName),_current,ex.getTargetException());
      if (reply == ErrorHandler.CONTINUE) {
        _attributes.clear();
        _attributeNameList.clear();
        _skipElement=1;
        _skipElementName=elementName;
        return;
      }
 else       if (reply == ErrorHandler.CANCEL) {
        throw new XmlException("String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
    }
    throw new XmlException("String_Node_Str" + elementName + "String_Node_Str"+ ex.getTargetException(),_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber(),ex.getTargetException());
  }
catch (  Exception ex) {
    if (_handler != null) {
      int reply=_handler.handleError(_getCurrentElement(elementName),_current,ex);
      if (reply == ErrorHandler.CONTINUE) {
        _attributes.clear();
        _attributeNameList.clear();
        _skipElement=1;
        _skipElementName=elementName;
        return;
      }
 else       if (reply == ErrorHandler.CANCEL) {
        throw new XmlException("String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
    }
    if (ex instanceof XmlException) {
      throw (XmlException)ex;
    }
 else {
      throw new XmlException("String_Node_Str" + elementName + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber(),ex);
    }
  }
  _attributes.clear();
  _attributeNameList.clear();
}

Fixed version (ground truth):
/** 
 * Start an element. This is called at the beginning of each XML element.  By the time it is called, all of the attributes for the element will already have been reported using the attribute() method.  Unrecognized elements are ignored.
 * @param elementName The element type name.
 * @exception XmlException If the element produces an errorin constructing the model.
 */
public void startElement(String elementName) throws XmlException {
  try {
    if (_skipElement <= 0) {
      if (_configureNesting > 0 || _docNesting > 0) {
        if (elementName.equals("String_Node_Str")) {
          _configureNesting++;
        }
 else         if (elementName.equals("String_Node_Str")) {
          _docNesting++;
        }
        _currentCharData.append(_getCurrentElement(elementName));
        _attributes.clear();
        _attributeNameList.clear();
        return;
      }
    }
    if (_skipRendition) {
      return;
    }
    boolean undoEnabled=_undoEnabled && _isUndoableElement(elementName);
    if (undoEnabled) {
      boolean childNodesUndoable=true;
      if (_undoContext != null) {
        _undoContexts.push(_undoContext);
        childNodesUndoable=_undoContext.hasUndoableChildren();
      }
      _undoContext=new UndoContext(childNodesUndoable);
      if (_undoDebug) {
        System.out.println("String_Node_Str" + elementName);
      }
    }
    if (_skipElement > 0) {
      if (elementName.equals(_skipElementName)) {
        if (_skipElementIsNew) {
          _skipElementIsNew=false;
        }
 else {
          _skipElement++;
        }
      }
      return;
    }
    if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      String source=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      ComponentEntity previous=_searchForEntity(entityName);
      boolean existedAlready=false;
      if (previous != null) {
        existedAlready=true;
      }
      NamedObj newEntity=_createEntity(className,entityName,source);
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
      }
      _linkRequests=new LinkedList();
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=newEntity.toplevel();
        _toplevel.setDeferChangeRequests(true);
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      if (!existedAlready) {
        ((Prototype)newEntity).setClassDefinition(true);
        NamedObj.MoMLInfo info=newEntity.getMoMLInfo();
        info.className=newEntity.getFullName();
        info.superclass=className;
      }
 else {
        if (!previous.isClassDefinition()) {
          previous.setClassDefinition(true);
          NamedObj.MoMLInfo info=previous.getMoMLInfo();
          info.superclass=info.className;
          info.className=previous.getFullName();
        }
      }
      _current=newEntity;
      _namespace=_DEFAULT_NAMESPACE;
      if (undoEnabled && _undoContext.isUndoable()) {
        if (existedAlready) {
          if (previous.isClassDefinition()) {
            _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
            _undoContext.appendClosingUndoMoML("String_Node_Str");
          }
 else {
            _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
            _undoContext.appendClosingUndoMoML("String_Node_Str");
          }
          _undoContext.setChildrenUndoable(true);
        }
 else {
          _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      _checkClass(_current,Configurable.class,"String_Node_Str" + "String_Node_Str" + _current);
      _configureSource=(String)_attributes.get("String_Node_Str");
      _currentCharData=new StringBuffer();
      _configureNesting++;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      NamedObj deletedEntity=_deleteEntity(entityName);
      if (_current != null) {
        _pushContext();
      }
      _current=deletedEntity;
      _namespace=_DEFAULT_NAMESPACE;
      if (undoEnabled && _undoContext.isUndoable()) {
        _undoContext.setChildrenUndoable(false);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      NamedObj deletedPort=_deletePort(portName,entityName);
      if (_current != null) {
        _pushContext();
      }
      _current=deletedPort;
      _namespace=_DEFAULT_NAMESPACE;
      if (undoEnabled && _undoContext.isUndoable()) {
        _undoContext.setChildrenUndoable(false);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String propName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propName,"String_Node_Str");
      NamedObj deletedProp=_deleteProperty(propName);
      if (_current != null) {
        _pushContext();
      }
      _current=deletedProp;
      _namespace=_DEFAULT_NAMESPACE;
      if (undoEnabled && _undoContext.isUndoable()) {
        _undoContext.appendUndoMoML(deletedProp.exportMoML());
        _undoContext.setChildrenUndoable(false);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      NamedObj deletedRelation=_deleteRelation(relationName);
      if (_current != null) {
        _pushContext();
      }
      _current=deletedRelation;
      _namespace=_DEFAULT_NAMESPACE;
      if (undoEnabled && _undoContext.isUndoable()) {
        _undoContext.setChildrenUndoable(false);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      _checkForNull(className,"String_Node_Str");
      String dirName=(String)_attributes.get("String_Node_Str");
      _checkForNull(dirName,"String_Node_Str");
      _checkClass(_current,CompositeActor.class,"String_Node_Str" + "String_Node_Str" + _current);
      Object[] arguments=new Object[2];
      arguments[0]=_current;
      arguments[1]=dirName;
      _pushContext();
      Class newClass=Class.forName(className,true,_classLoader);
      _current=_createInstance(newClass,arguments);
      _namespace=_DEFAULT_NAMESPACE;
    }
 else     if (elementName.equals("String_Node_Str")) {
      _currentDocName=(String)_attributes.get("String_Node_Str");
      _currentCharData=new StringBuffer();
      _docNesting++;
    }
 else     if (elementName.equals("String_Node_Str") || elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      String source=(String)_attributes.get("String_Node_Str");
      ComponentEntity previous=_searchForEntity(entityName);
      boolean existedAlready=false;
      if (previous != null) {
        existedAlready=true;
      }
      NamedObj newEntity=_createEntity(className,entityName,source);
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
      }
      _linkRequests=new LinkedList();
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=newEntity.toplevel();
        _toplevel.setDeferChangeRequests(true);
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      _current=newEntity;
      _namespace=_DEFAULT_NAMESPACE;
      if (undoEnabled && _undoContext.isUndoable()) {
        if (existedAlready) {
          _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
          _undoContext.appendClosingUndoMoML("String_Node_Str");
          _undoContext.setChildrenUndoable(true);
        }
 else {
          _undoContext.appendUndoMoML("String_Node_Str" + entityName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String groupName=(String)_attributes.get("String_Node_Str");
      if (groupName != null) {
        _namespaces.push(_namespace);
        _namespaceTranslations.push(_namespaceTranslationTable);
        if (groupName.equals("String_Node_Str")) {
          _namespace=_AUTO_NAMESPACE;
          _namespaceTranslationTable=new HashMap();
        }
 else {
          _namespace=groupName;
        }
      }
 else {
        _namespaces.push(_DEFAULT_NAMESPACE);
        _namespaceTranslations.push(_namespaceTranslationTable);
        _namespace=_DEFAULT_NAMESPACE;
      }
      if (undoEnabled && _undoContext.isUndoable()) {
        _undoContext.appendUndoMoML("String_Node_Str");
        _undoContext.appendClosingUndoMoML("String_Node_Str");
        _undoContext.setChildrenUndoable(true);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String source=(String)_attributes.get("String_Node_Str");
      _checkForNull(source,"String_Node_Str");
      boolean skip=false;
      if (inputFileNamesToSkip != null) {
        Iterator inputFileNames=inputFileNamesToSkip.iterator();
        while (inputFileNames.hasNext()) {
          String inputFileName=(String)inputFileNames.next();
          if (source.endsWith(inputFileName)) {
            skip=true;
            break;
          }
        }
      }
      if (!skip) {
        MoMLParser newParser=new MoMLParser(_workspace,_classLoader);
        newParser.setContext(_current);
        newParser._propagator=_propagator;
        _parse(newParser,_base,source);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      String insertAtSpec=(String)_attributes.get("String_Node_Str");
      String insertInsideAtSpec=(String)_attributes.get("String_Node_Str");
      LinkRequest request=new LinkRequest(portName,relationName,insertAtSpec,insertInsideAtSpec);
      if (_linkRequests != null) {
        _linkRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      _checkClass(_current,Entity.class,"String_Node_Str" + "String_Node_Str" + _current);
      Entity container=(Entity)_current;
      Class newClass=null;
      if (className != null && !className.trim().equals("String_Node_Str")) {
        newClass=Class.forName(className,true,_classLoader);
      }
      Port port=container.getPort(portName);
      boolean alreadyExisted=(port != null);
      if (port != null) {
        if (newClass != null) {
          _checkClass(port,newClass,"String_Node_Str" + portName + "String_Node_Str"+ className);
        }
      }
 else {
        if (newClass == null) {
          port=container.newPort(portName);
        }
 else {
          Object[] arguments=new Object[2];
          arguments[0]=container;
          arguments[1]=portName;
          port=(Port)_createInstance(newClass,arguments);
        }
      }
      _pushContext();
      _current=port;
      _namespace=_DEFAULT_NAMESPACE;
      if (undoEnabled && _undoContext.isUndoable()) {
        if (alreadyExisted) {
          _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str");
          if (className != null) {
            _undoContext.appendUndoMoML("String_Node_Str" + className + "String_Node_Str");
          }
          _undoContext.appendUndoMoML("String_Node_Str");
          _undoContext.appendClosingUndoMoML("String_Node_Str");
          _undoContext.setChildrenUndoable(true);
        }
 else {
          _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
      }
      if (port instanceof IOPort) {
        String direction=(String)_attributes.get("String_Node_Str");
        if (direction != null) {
          IOPort ioport=(IOPort)port;
          boolean isOutput=direction.equals("String_Node_Str") || direction.equals("String_Node_Str");
          boolean isInput=direction.equals("String_Node_Str") || direction.equals("String_Node_Str");
          if (alreadyExisted && ioport.isClassElement() && (_propagator == null)) {
            if (ioport.isInput() != isInput || ioport.isOutput() != isOutput) {
              throw new IllegalActionException(ioport,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
            }
          }
          ioport.setOutput(isOutput);
          ioport.setInput(isInput);
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String propertyName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propertyName,"String_Node_Str");
      String value=(String)_attributes.get("String_Node_Str");
      _handlePropertyElement(className,propertyName,value);
    }
 else     if (elementName.equals("String_Node_Str")) {
      String className=(String)_attributes.get("String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      CompositeEntity container=(CompositeEntity)_current;
      Class newClass=null;
      if (className != null) {
        newClass=Class.forName(className,true,_classLoader);
      }
      Relation relation=container.getRelation(relationName);
      boolean alreadyExisted=(relation != null);
      if (relation == null) {
        NamedObj newRelation=null;
        _pushContext();
        if (newClass == null) {
          newRelation=container.newRelation(relationName);
        }
 else {
          Object[] arguments=new Object[2];
          arguments[0]=(CompositeEntity)_current;
          arguments[1]=relationName;
          newRelation=_createInstance(newClass,arguments);
        }
        _namespace=_DEFAULT_NAMESPACE;
        _current=newRelation;
      }
 else {
        if (newClass != null) {
          _checkClass(relation,newClass,"String_Node_Str" + relationName + "String_Node_Str"+ className);
        }
        _pushContext();
        _current=relation;
        _namespace=_DEFAULT_NAMESPACE;
      }
      if (undoEnabled && _undoContext.isUndoable()) {
        if (alreadyExisted) {
          _undoContext.appendUndoMoML("String_Node_Str" + relationName + "String_Node_Str");
          if (className != null) {
            _undoContext.appendUndoMoML("String_Node_Str" + className + "String_Node_Str");
          }
          _undoContext.appendUndoMoML("String_Node_Str");
          _undoContext.appendClosingUndoMoML("String_Node_Str");
          _undoContext.setChildrenUndoable(true);
        }
 else {
          _undoContext.appendUndoMoML("String_Node_Str" + relationName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String newName=(String)_attributes.get("String_Node_Str");
      _checkForNull(newName,"String_Node_Str");
      if (_current != null) {
        String oldName=_current.getName();
        if (!oldName.equals(newName) && _current.isClassElement() && (_propagator == null)) {
          throw new IllegalActionException(_current,"String_Node_Str" + newName + "String_Node_Str");
        }
        _current.setName(newName);
        if (undoEnabled && _undoContext.isUndoable()) {
          try {
            UndoContext parentContext=(UndoContext)_undoContexts.peek();
            parentContext.applyRename(newName);
            _undoContext.appendUndoMoML("String_Node_Str" + oldName + "String_Node_Str");
            _undoContext.setChildrenUndoable(false);
          }
 catch (          Exception e) {
          }
        }
        if ((_current instanceof Prototype) && ((Prototype)_current).isClassDefinition()) {
          List deferredFrom=((Prototype)_current).getDeferredFrom();
          if (deferredFrom != null) {
            Iterator deferrers=deferredFrom.iterator();
            while (deferrers.hasNext()) {
              WeakReference reference=(WeakReference)deferrers.next();
              Prototype deferrer=(Prototype)reference.get();
              if (deferrer != null) {
                String replacementName=newName;
                if (deferrer.isClassDefinition()) {
                  if (deferrer.getMoMLInfo().superclass.startsWith("String_Node_Str")) {
                    replacementName=_current.getFullName();
                  }
                  deferrer.getMoMLInfo().superclass=replacementName;
                }
 else {
                  if (deferrer.getMoMLInfo().className.startsWith("String_Node_Str")) {
                    replacementName=_current.getFullName();
                  }
                  deferrer.getMoMLInfo().className=replacementName;
                }
              }
            }
          }
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      _skipRendition=true;
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("String_Node_Str");
      _checkForNull(portName,"String_Node_Str");
      String relationName=(String)_attributes.get("String_Node_Str");
      String indexSpec=(String)_attributes.get("String_Node_Str");
      String insideIndexSpec=(String)_attributes.get("String_Node_Str");
      UnlinkRequest request=new UnlinkRequest(portName,relationName,indexSpec,insideIndexSpec);
      if (_linkRequests != null) {
        _linkRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String vertexName=(String)_attributes.get("String_Node_Str");
      _checkForNull(vertexName,"String_Node_Str");
      _checkClass(_current,Relation.class,"String_Node_Str" + "String_Node_Str" + _current);
      Vertex previous=(Vertex)_current.getAttribute(vertexName);
      String previousValue=null;
      if (previous != null) {
        previousValue=previous.getExpression();
      }
      Vertex vertex=new Vertex((Relation)_current,vertexName);
      String value=(String)_attributes.get("String_Node_Str");
      if (value != null) {
        vertex.setExpression(value);
        _paramsToParse.add(vertex);
      }
      _pushContext();
      _current=vertex;
      _namespace=_DEFAULT_NAMESPACE;
      if (undoEnabled && _undoContext.isUndoable()) {
        _undoContext.appendUndoMoML("String_Node_Str" + vertexName + "String_Node_Str");
        if (previousValue != null) {
          _undoContext.appendUndoMoML("String_Node_Str" + previousValue + "String_Node_Str");
        }
        _undoContext.appendUndoMoML("String_Node_Str");
        _undoContext.setChildrenUndoable(true);
        _undoContext.appendClosingUndoMoML("String_Node_Str");
      }
    }
 else {
      if (_unrecognized == null) {
        _unrecognized=new LinkedList();
      }
      _unrecognized.add(elementName);
    }
  }
 catch (  InvocationTargetException ex) {
    if (_handler != null) {
      int reply=_handler.handleError(_getCurrentElement(elementName),_current,ex.getTargetException());
      if (reply == ErrorHandler.CONTINUE) {
        _attributes.clear();
        _attributeNameList.clear();
        _skipElement=1;
        _skipElementName=elementName;
        return;
      }
 else       if (reply == ErrorHandler.CANCEL) {
        throw new XmlException("String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
    }
    throw new XmlException("String_Node_Str" + elementName + "String_Node_Str"+ ex.getTargetException(),_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber(),ex.getTargetException());
  }
catch (  Exception ex) {
    if (_handler != null) {
      int reply=_handler.handleError(_getCurrentElement(elementName),_current,ex);
      if (reply == ErrorHandler.CONTINUE) {
        _attributes.clear();
        _attributeNameList.clear();
        _skipElement=1;
        _skipElementName=elementName;
        return;
      }
 else       if (reply == ErrorHandler.CANCEL) {
        throw new XmlException("String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
    }
    if (ex instanceof XmlException) {
      throw (XmlException)ex;
    }
 else {
      throw new XmlException("String_Node_Str" + elementName + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber(),ex);
    }
  }
  _attributes.clear();
  _attributeNameList.clear();
}