Program: 74249
Project: 74249
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 {
  boolean pushedLinkRequests=false;
  boolean pushedDeleteRequests=false;
  boolean pushedUndoContexts=false;
  boolean exceptionThrown=false;
  _namespacesPushed=false;
  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;
    }
    _undoEnabled=_undoEnabled && _isUndoableElement(elementName);
    if (_undoContext != null) {
      _undoContexts.push(_undoContext);
      pushedUndoContexts=true;
      _undoEnabled=_undoEnabled && _undoContext.hasUndoableChildren();
    }
    _undoContext=new UndoContext(_undoEnabled);
    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");
      Entity entity=_searchForEntity(entityName,_current);
      boolean existedAlready=(entity != null);
      if (!existedAlready) {
        NamedObj candidate=_createEntity(className,entityName,source);
        if (candidate instanceof Entity) {
          entity=(Entity)candidate;
        }
 else {
          throw new IllegalActionException(_current,"String_Node_Str" + entityName + "String_Node_Str"+ "String_Node_Str"+ className);
        }
      }
      if (_deleteRequests != null) {
        _deleteRequestStack.push(_deleteRequests);
        pushedDeleteRequests=true;
      }
      _deleteRequests=new LinkedList();
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
        pushedLinkRequests=true;
      }
      _linkRequests=new LinkedList();
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=entity.toplevel();
        _toplevel.setDeferringChangeRequests(true);
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      boolean converted=false;
      if (!existedAlready) {
        entity.setClassDefinition(true);
        entity.setClassName(className);
      }
 else {
        if (!entity.isClassDefinition()) {
          entity.setClassDefinition(true);
          converted=true;
        }
      }
      _current=entity;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled) {
        if (existedAlready) {
          if (!converted) {
            _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);
          _undoContext.setUndoable(false);
          _undoEnabled=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");
      DeleteRequest request=new DeleteRequest(_DELETE_ENTITY,entityName,null);
      if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
        _deleteRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 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");
      Port toDelete=null;
      try {
        toDelete=_searchForPort(portName);
      }
 catch (      XmlException ex) {
      }
      if (toDelete != null) {
        NamedObj container=toDelete.getContainer();
        if (container != null && container instanceof Entity) {
          Attribute attribute=((Entity)container).getAttribute(portName);
          if (attribute != null && attribute instanceof PortParameter) {
            DeleteRequest request=new DeleteRequest(_DELETE_PROPERTY,attribute.getName(),null);
            if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
              _deleteRequests.add(request);
            }
 else {
              request.execute();
            }
          }
        }
      }
      DeleteRequest request=new DeleteRequest(_DELETE_PORT,portName,entityName);
      if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
        _deleteRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String propName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propName,"String_Node_Str");
      DeleteRequest request=new DeleteRequest(_DELETE_PROPERTY,propName,null);
      Attribute toDelete=_searchForAttribute(propName);
      if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
        _deleteRequests.add(request);
      }
 else {
        request.execute();
      }
      NamedObj container=toDelete.getContainer();
      if (container != null && container instanceof Entity) {
        Port port=((Entity)container).getPort(propName);
        if (port != null && port instanceof ParameterPort) {
          request=new DeleteRequest(_DELETE_PORT,port.getName(),container.getFullName());
          if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
            _deleteRequests.add(request);
          }
 else {
            request.execute();
          }
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      DeleteRequest request=new DeleteRequest(_DELETE_RELATION,relationName,null);
      if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
        _deleteRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 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")) {
      String displayName=(String)_attributes.get("String_Node_Str");
      if (_current != null) {
        Iterator derivedObjects=_current.getDerivedList().iterator();
        String currentName=_current.getName();
        while (derivedObjects.hasNext()) {
          NamedObj derived=(NamedObj)derivedObjects.next();
          if (derived.getName().equals(currentName)) {
            if (displayName != null) {
              if (displayName.equals(currentName)) {
                derived.setDisplayName(null);
              }
 else {
                derived.setDisplayName(displayName);
              }
            }
          }
        }
        String oldDisplayName=_current.getDisplayName();
        if (displayName != null) {
          if (displayName.equals(currentName) || displayName.equals("String_Node_Str")) {
            _current.setDisplayName(null);
          }
 else {
            _current.setDisplayName(displayName);
          }
          if (_undoEnabled) {
            _undoContext.appendUndoMoML("String_Node_Str" + StringUtilities.escapeForXML(oldDisplayName) + "String_Node_Str");
            _undoContext.setChildrenUndoable(false);
          }
        }
      }
    }
 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");
      Entity entity=_searchForEntity(entityName,_current);
      boolean existedAlready=(entity != null);
      boolean converted=false;
      if (existedAlready) {
        if (entity.isClassDefinition()) {
          entity.setClassDefinition(false);
          converted=true;
        }
      }
 else {
        NamedObj candidate=_createEntity(className,entityName,source);
        if (candidate instanceof Entity) {
          entity=(Entity)candidate;
          entity.setClassName(className);
        }
 else {
          throw new IllegalActionException(_current,"String_Node_Str" + entityName + "String_Node_Str"+ "String_Node_Str"+ className);
        }
      }
      if (_deleteRequests != null) {
        _deleteRequestStack.push(_deleteRequests);
        pushedDeleteRequests=true;
      }
      _deleteRequests=new LinkedList();
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
        pushedLinkRequests=true;
      }
      _linkRequests=new LinkedList();
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=entity.toplevel();
        _toplevel.setDeferringChangeRequests(true);
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      _current=entity;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled) {
        if (existedAlready) {
          if (!converted) {
            _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);
          _undoContext.setUndoable(false);
          _undoEnabled=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);
        _namespacesPushed=true;
        if (groupName.equals("String_Node_Str")) {
          _namespace=_AUTO_NAMESPACE;
          _namespaceTranslationTable=new HashMap();
        }
 else {
          _namespace=groupName;
        }
      }
 else {
        _namespaces.push(_DEFAULT_NAMESPACE);
        _namespaceTranslations.push(_namespaceTranslationTable);
        _namespacesPushed=true;
        _namespace=_DEFAULT_NAMESPACE;
        _namespaceTranslationTable=new HashMap();
      }
      if (_deleteRequests != null) {
        _deleteRequestStack.push(_deleteRequests);
        pushedDeleteRequests=true;
      }
      _deleteRequests=new LinkedList();
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
        pushedLinkRequests=true;
      }
      _linkRequests=new LinkedList();
      if (_undoEnabled) {
        _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) {
        boolean modified=isModified();
        MoMLParser newParser=new MoMLParser(_workspace,_classLoader);
        newParser.setContext(_current);
        setModified(modified);
        _parse(newParser,_base,source);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("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;
      if (portName != null) {
        request=new LinkRequest(portName,relationName,insertAtSpec,insertInsideAtSpec);
      }
 else {
        String relation1Name=(String)_attributes.get("String_Node_Str");
        String relation2Name=(String)_attributes.get("String_Node_Str");
        request=new LinkRequest(relation1Name,relation2Name);
      }
      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 {
        List derivedList=container.getDerivedList();
        Iterator derivedObjects=derivedList.iterator();
        while (derivedObjects.hasNext()) {
          Entity derived=(Entity)derivedObjects.next();
          if (derived.getPort(portName) != null) {
            throw new IllegalActionException(container,"String_Node_Str" + "String_Node_Str" + derived.getPort(portName).getFullName());
          }
        }
        if (newClass == null) {
          port=container.newPort(portName);
          if ((_topObjectsCreated != null) && (container == _originalContext)) {
            _topObjectsCreated.add(port);
          }
          port.propagateExistence();
        }
 else {
          Object[] arguments=new Object[2];
          arguments[0]=container;
          arguments[1]=portName;
          port=(Port)_createInstance(newClass,arguments);
          port.propagateExistence();
        }
      }
      _pushContext();
      _current=port;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled) {
        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);
          _undoContext.setUndoable(false);
          _undoEnabled=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.getDerivedLevel() < Integer.MAX_VALUE)) {
            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 createIfNecessary=(String)_attributes.get("String_Node_Str");
      String className=(String)_attributes.get("String_Node_Str");
      String propertyName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propertyName,"String_Node_Str");
      if (createIfNecessary != null && createIfNecessary.equals("String_Node_Str") && _current != null && propertyName != null && _current.getAttribute(propertyName) != null) {
      }
 else {
        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) {
        List derivedList=container.getDerivedList();
        Iterator derivedObjects=derivedList.iterator();
        while (derivedObjects.hasNext()) {
          CompositeEntity derived=(CompositeEntity)derivedObjects.next();
          if (derived.getRelation(relationName) != null) {
            throw new IllegalActionException(container,"String_Node_Str" + "String_Node_Str" + derived.getRelation(relationName).getFullName());
          }
        }
        NamedObj newRelation=null;
        _pushContext();
        if (newClass == null) {
          newRelation=container.newRelation(relationName);
          if ((_topObjectsCreated != null) && (container == _originalContext)) {
            _topObjectsCreated.add(newRelation);
          }
          newRelation.propagateExistence();
        }
 else {
          Object[] arguments=new Object[2];
          arguments[0]=_current;
          arguments[1]=relationName;
          newRelation=_createInstance(newClass,arguments);
          newRelation.propagateExistence();
        }
        _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) {
        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);
          _undoContext.setUndoable(false);
          _undoEnabled=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.getDerivedLevel() < Integer.MAX_VALUE)) {
          throw new IllegalActionException(_current,"String_Node_Str" + newName + "String_Node_Str");
        }
        Iterator derivedObjects=_current.getDerivedList().iterator();
        Set changedName=new HashSet();
        HashMap changedClassName=new HashMap();
        NamedObj derived=null;
        try {
          while (derivedObjects.hasNext()) {
            derived=(NamedObj)derivedObjects.next();
            if (derived.getName().equals(oldName)) {
              derived.setName(newName);
              changedName.add(derived);
            }
            if (derived instanceof Instantiable) {
              Instantiable parent=((Instantiable)derived).getParent();
              if ((parent != null) && ((parent == _current) || changedName.contains(parent))) {
                String previousClassName=derived.getClassName();
                int last=previousClassName.lastIndexOf(oldName);
                if (last < 0) {
                  throw new InternalErrorException("String_Node_Str" + derived.getFullName() + "String_Node_Str"+ oldName+ "String_Node_Str"+ previousClassName);
                }
                String newClassName=newName;
                if (last > 0) {
                  newClassName=previousClassName.substring(0,last) + newName;
                }
                derived.setClassName(newClassName);
                changedClassName.put(derived,previousClassName);
              }
            }
          }
        }
 catch (        NameDuplicationException ex) {
          Iterator toUndo=changedName.iterator();
          while (toUndo.hasNext()) {
            NamedObj revert=(NamedObj)toUndo.next();
            revert.setName(oldName);
          }
          Iterator classNameFixes=changedClassName.entrySet().iterator();
          while (classNameFixes.hasNext()) {
            Map.Entry revert=(Map.Entry)classNameFixes.next();
            NamedObj toFix=(NamedObj)revert.getKey();
            String previousClassName=(String)revert.getValue();
            toFix.setClassName(previousClassName);
          }
          throw new IllegalActionException(_current,ex,"String_Node_Str" + "String_Node_Str" + derived.getFullName());
        }
        _current.setName(newName);
        if (_undoEnabled) {
          UndoContext parentContext=(UndoContext)_undoContexts.peek();
          parentContext.applyRename(newName);
          _undoContext.appendUndoMoML("String_Node_Str" + oldName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
        if ((_current instanceof Instantiable) && ((Instantiable)_current).isClassDefinition()) {
          List deferredFrom=((Instantiable)_current).getChildren();
          if (deferredFrom != null) {
            Iterator deferrers=deferredFrom.iterator();
            while (deferrers.hasNext()) {
              WeakReference reference=(WeakReference)deferrers.next();
              InstantiableNamedObj deferrer=(InstantiableNamedObj)reference.get();
              if (deferrer != null) {
                String replacementName=newName;
                if (deferrer.getClassName().startsWith("String_Node_Str")) {
                  replacementName=_current.getFullName();
                }
                deferrer.setClassName(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");
      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;
      if (portName != null) {
        request=new UnlinkRequest(portName,relationName,indexSpec,insideIndexSpec);
      }
 else {
        String relation1Name=(String)_attributes.get("String_Node_Str");
        String relation2Name=(String)_attributes.get("String_Node_Str");
        request=new UnlinkRequest(relation1Name,relation2Name);
      }
      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=previous;
      if (vertex == null) {
        vertex=new Vertex((Relation)_current,vertexName);
        vertex.propagateExistence();
      }
      String value=(String)_attributes.get("String_Node_Str");
      if ((value != null) && !value.equals(previousValue)) {
        vertex.setExpression(value);
        try {
          vertex.propagateValue();
          _paramsToParse.add(vertex);
        }
 catch (        IllegalActionException ex) {
          vertex.setExpression(previousValue);
          throw ex;
        }
      }
      _pushContext();
      _current=vertex;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled) {
        _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) {
    exceptionThrown=true;
    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(),_getLineNumber(),_getColumnNumber());
      }
    }
    throw new XmlException("String_Node_Str" + elementName + "String_Node_Str"+ ex.getTargetException(),_currentExternalEntity(),_getLineNumber(),_getColumnNumber(),ex.getTargetException());
  }
catch (  Exception ex) {
    exceptionThrown=true;
    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) {
        if (_toplevel != null) {
          _toplevel.setDeferringChangeRequests(_previousDeferStatus);
          _toplevel.executeChangeRequests();
        }
        throw new XmlException("String_Node_Str",_currentExternalEntity(),_getLineNumber(),_getColumnNumber());
      }
    }
    if (_toplevel != null) {
      _toplevel.setDeferringChangeRequests(_previousDeferStatus);
      _toplevel.executeChangeRequests();
    }
    if (ex instanceof XmlException) {
      throw (XmlException)ex;
    }
 else {
      throw new XmlException("String_Node_Str" + elementName + "String_Node_Str",_currentExternalEntity(),_getLineNumber(),_getColumnNumber(),ex);
    }
  }
 finally {
    _attributes.clear();
    _attributeNameList.clear();
    if (exceptionThrown) {
      if (pushedDeleteRequests) {
        try {
          _deleteRequests=(List)_deleteRequestStack.pop();
        }
 catch (        EmptyStackException ex) {
          _deleteRequests=null;
        }
      }
      if (pushedLinkRequests) {
        try {
          _linkRequests=(List)_linkRequestStack.pop();
        }
 catch (        EmptyStackException ex) {
          _linkRequests=null;
        }
      }
      if (_namespacesPushed) {
        try {
          _namespace=(String)_namespaces.pop();
          _namespaceTranslationTable=(Map)_namespaceTranslations.pop();
        }
 catch (        EmptyStackException ex) {
          _namespace=_DEFAULT_NAMESPACE;
        }
      }
      if (pushedUndoContexts) {
        try {
          _undoContext=(UndoContext)_undoContexts.pop();
        }
 catch (        EmptyStackException ex) {
        }
      }
    }
  }
}

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 {
  boolean pushedLinkRequests=false;
  boolean pushedDeleteRequests=false;
  boolean pushedUndoContexts=false;
  boolean exceptionThrown=false;
  _namespacesPushed=false;
  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;
    }
    _undoEnabled=_undoEnabled && _isUndoableElement(elementName);
    if (_undoContext != null) {
      _undoContexts.push(_undoContext);
      pushedUndoContexts=true;
      _undoEnabled=_undoEnabled && _undoContext.hasUndoableChildren();
    }
    _undoContext=new UndoContext(_undoEnabled);
    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");
      Entity entity=_searchForEntity(entityName,_current);
      boolean existedAlready=(entity != null);
      if (!existedAlready) {
        NamedObj candidate=_createEntity(className,entityName,source,true);
        if (candidate instanceof Entity) {
          entity=(Entity)candidate;
        }
 else {
          throw new IllegalActionException(_current,"String_Node_Str" + entityName + "String_Node_Str"+ "String_Node_Str"+ className);
        }
      }
      if (_deleteRequests != null) {
        _deleteRequestStack.push(_deleteRequests);
        pushedDeleteRequests=true;
      }
      _deleteRequests=new LinkedList();
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
        pushedLinkRequests=true;
      }
      _linkRequests=new LinkedList();
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=entity.toplevel();
        _toplevel.setDeferringChangeRequests(true);
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      boolean converted=false;
      if (!existedAlready) {
        entity.setClassDefinition(true);
        entity.setClassName(className);
      }
 else {
        if (!entity.isClassDefinition()) {
          entity.setClassDefinition(true);
          converted=true;
        }
      }
      _current=entity;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled) {
        if (existedAlready) {
          if (!converted) {
            _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);
          _undoContext.setUndoable(false);
          _undoEnabled=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");
      DeleteRequest request=new DeleteRequest(_DELETE_ENTITY,entityName,null);
      if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
        _deleteRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 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");
      Port toDelete=null;
      try {
        toDelete=_searchForPort(portName);
      }
 catch (      XmlException ex) {
      }
      if (toDelete != null) {
        NamedObj container=toDelete.getContainer();
        if (container != null && container instanceof Entity) {
          Attribute attribute=((Entity)container).getAttribute(portName);
          if (attribute != null && attribute instanceof PortParameter) {
            DeleteRequest request=new DeleteRequest(_DELETE_PROPERTY,attribute.getName(),null);
            if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
              _deleteRequests.add(request);
            }
 else {
              request.execute();
            }
          }
        }
      }
      DeleteRequest request=new DeleteRequest(_DELETE_PORT,portName,entityName);
      if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
        _deleteRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String propName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propName,"String_Node_Str");
      DeleteRequest request=new DeleteRequest(_DELETE_PROPERTY,propName,null);
      Attribute toDelete=_searchForAttribute(propName);
      if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
        _deleteRequests.add(request);
      }
 else {
        request.execute();
      }
      NamedObj container=toDelete.getContainer();
      if (container != null && container instanceof Entity) {
        Port port=((Entity)container).getPort(propName);
        if (port != null && port instanceof ParameterPort) {
          request=new DeleteRequest(_DELETE_PORT,port.getName(),container.getFullName());
          if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
            _deleteRequests.add(request);
          }
 else {
            request.execute();
          }
        }
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String relationName=(String)_attributes.get("String_Node_Str");
      _checkForNull(relationName,"String_Node_Str");
      DeleteRequest request=new DeleteRequest(_DELETE_RELATION,relationName,null);
      if ((_deleteRequests != null) && _current instanceof InstantiableNamedObj) {
        _deleteRequests.add(request);
      }
 else {
        request.execute();
      }
    }
 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")) {
      String displayName=(String)_attributes.get("String_Node_Str");
      if (_current != null) {
        Iterator derivedObjects=_current.getDerivedList().iterator();
        String currentName=_current.getName();
        while (derivedObjects.hasNext()) {
          NamedObj derived=(NamedObj)derivedObjects.next();
          if (derived.getName().equals(currentName)) {
            if (displayName != null) {
              if (displayName.equals(currentName)) {
                derived.setDisplayName(null);
              }
 else {
                derived.setDisplayName(displayName);
              }
            }
          }
        }
        String oldDisplayName=_current.getDisplayName();
        if (displayName != null) {
          if (displayName.equals(currentName) || displayName.equals("String_Node_Str")) {
            _current.setDisplayName(null);
          }
 else {
            _current.setDisplayName(displayName);
          }
          if (_undoEnabled) {
            _undoContext.appendUndoMoML("String_Node_Str" + StringUtilities.escapeForXML(oldDisplayName) + "String_Node_Str");
            _undoContext.setChildrenUndoable(false);
          }
        }
      }
    }
 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");
      Entity entity=_searchForEntity(entityName,_current);
      boolean existedAlready=(entity != null);
      boolean converted=false;
      if (existedAlready) {
        if (entity.isClassDefinition()) {
          entity.setClassDefinition(false);
          converted=true;
        }
      }
 else {
        NamedObj candidate=_createEntity(className,entityName,source,false);
        if (candidate instanceof Entity) {
          entity=(Entity)candidate;
          entity.setClassName(className);
        }
 else {
          throw new IllegalActionException(_current,"String_Node_Str" + entityName + "String_Node_Str"+ "String_Node_Str"+ className);
        }
      }
      if (_deleteRequests != null) {
        _deleteRequestStack.push(_deleteRequests);
        pushedDeleteRequests=true;
      }
      _deleteRequests=new LinkedList();
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
        pushedLinkRequests=true;
      }
      _linkRequests=new LinkedList();
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=entity.toplevel();
        _toplevel.setDeferringChangeRequests(true);
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      _current=entity;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled) {
        if (existedAlready) {
          if (!converted) {
            _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);
          _undoContext.setUndoable(false);
          _undoEnabled=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);
        _namespacesPushed=true;
        if (groupName.equals("String_Node_Str")) {
          _namespace=_AUTO_NAMESPACE;
          _namespaceTranslationTable=new HashMap();
        }
 else {
          _namespace=groupName;
        }
      }
 else {
        _namespaces.push(_DEFAULT_NAMESPACE);
        _namespaceTranslations.push(_namespaceTranslationTable);
        _namespacesPushed=true;
        _namespace=_DEFAULT_NAMESPACE;
        _namespaceTranslationTable=new HashMap();
      }
      if (_deleteRequests != null) {
        _deleteRequestStack.push(_deleteRequests);
        pushedDeleteRequests=true;
      }
      _deleteRequests=new LinkedList();
      if (_linkRequests != null) {
        _linkRequestStack.push(_linkRequests);
        pushedLinkRequests=true;
      }
      _linkRequests=new LinkedList();
      if (_undoEnabled) {
        _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) {
        boolean modified=isModified();
        MoMLParser newParser=new MoMLParser(_workspace,_classLoader);
        newParser.setContext(_current);
        setModified(modified);
        _parse(newParser,_base,source);
      }
    }
 else     if (elementName.equals("String_Node_Str")) {
      String portName=(String)_attributes.get("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;
      if (portName != null) {
        request=new LinkRequest(portName,relationName,insertAtSpec,insertInsideAtSpec);
      }
 else {
        String relation1Name=(String)_attributes.get("String_Node_Str");
        String relation2Name=(String)_attributes.get("String_Node_Str");
        request=new LinkRequest(relation1Name,relation2Name);
      }
      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 {
        List derivedList=container.getDerivedList();
        Iterator derivedObjects=derivedList.iterator();
        while (derivedObjects.hasNext()) {
          Entity derived=(Entity)derivedObjects.next();
          if (derived.getPort(portName) != null) {
            throw new IllegalActionException(container,"String_Node_Str" + "String_Node_Str" + derived.getPort(portName).getFullName());
          }
        }
        if (newClass == null) {
          port=container.newPort(portName);
          if ((_topObjectsCreated != null) && (container == _originalContext)) {
            _topObjectsCreated.add(port);
          }
          port.propagateExistence();
        }
 else {
          Object[] arguments=new Object[2];
          arguments[0]=container;
          arguments[1]=portName;
          port=(Port)_createInstance(newClass,arguments);
          port.propagateExistence();
        }
      }
      _pushContext();
      _current=port;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled) {
        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);
          _undoContext.setUndoable(false);
          _undoEnabled=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.getDerivedLevel() < Integer.MAX_VALUE)) {
            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 createIfNecessary=(String)_attributes.get("String_Node_Str");
      String className=(String)_attributes.get("String_Node_Str");
      String propertyName=(String)_attributes.get("String_Node_Str");
      _checkForNull(propertyName,"String_Node_Str");
      if (createIfNecessary != null && createIfNecessary.equals("String_Node_Str") && _current != null && propertyName != null && _current.getAttribute(propertyName) != null) {
      }
 else {
        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) {
        List derivedList=container.getDerivedList();
        Iterator derivedObjects=derivedList.iterator();
        while (derivedObjects.hasNext()) {
          CompositeEntity derived=(CompositeEntity)derivedObjects.next();
          if (derived.getRelation(relationName) != null) {
            throw new IllegalActionException(container,"String_Node_Str" + "String_Node_Str" + derived.getRelation(relationName).getFullName());
          }
        }
        NamedObj newRelation=null;
        _pushContext();
        if (newClass == null) {
          newRelation=container.newRelation(relationName);
          if ((_topObjectsCreated != null) && (container == _originalContext)) {
            _topObjectsCreated.add(newRelation);
          }
          newRelation.propagateExistence();
        }
 else {
          Object[] arguments=new Object[2];
          arguments[0]=_current;
          arguments[1]=relationName;
          newRelation=_createInstance(newClass,arguments);
          newRelation.propagateExistence();
        }
        _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) {
        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);
          _undoContext.setUndoable(false);
          _undoEnabled=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.getDerivedLevel() < Integer.MAX_VALUE)) {
          throw new IllegalActionException(_current,"String_Node_Str" + newName + "String_Node_Str");
        }
        Iterator derivedObjects=_current.getDerivedList().iterator();
        Set changedName=new HashSet();
        HashMap changedClassName=new HashMap();
        NamedObj derived=null;
        try {
          while (derivedObjects.hasNext()) {
            derived=(NamedObj)derivedObjects.next();
            if (derived.getName().equals(oldName)) {
              derived.setName(newName);
              changedName.add(derived);
            }
            if (derived instanceof Instantiable) {
              Instantiable parent=((Instantiable)derived).getParent();
              if ((parent != null) && ((parent == _current) || changedName.contains(parent))) {
                String previousClassName=derived.getClassName();
                int last=previousClassName.lastIndexOf(oldName);
                if (last < 0) {
                  throw new InternalErrorException("String_Node_Str" + derived.getFullName() + "String_Node_Str"+ oldName+ "String_Node_Str"+ previousClassName);
                }
                String newClassName=newName;
                if (last > 0) {
                  newClassName=previousClassName.substring(0,last) + newName;
                }
                derived.setClassName(newClassName);
                changedClassName.put(derived,previousClassName);
              }
            }
          }
        }
 catch (        NameDuplicationException ex) {
          Iterator toUndo=changedName.iterator();
          while (toUndo.hasNext()) {
            NamedObj revert=(NamedObj)toUndo.next();
            revert.setName(oldName);
          }
          Iterator classNameFixes=changedClassName.entrySet().iterator();
          while (classNameFixes.hasNext()) {
            Map.Entry revert=(Map.Entry)classNameFixes.next();
            NamedObj toFix=(NamedObj)revert.getKey();
            String previousClassName=(String)revert.getValue();
            toFix.setClassName(previousClassName);
          }
          throw new IllegalActionException(_current,ex,"String_Node_Str" + "String_Node_Str" + derived.getFullName());
        }
        _current.setName(newName);
        if (_undoEnabled) {
          UndoContext parentContext=(UndoContext)_undoContexts.peek();
          parentContext.applyRename(newName);
          _undoContext.appendUndoMoML("String_Node_Str" + oldName + "String_Node_Str");
          _undoContext.setChildrenUndoable(false);
        }
        if ((_current instanceof Instantiable) && ((Instantiable)_current).isClassDefinition()) {
          List deferredFrom=((Instantiable)_current).getChildren();
          if (deferredFrom != null) {
            Iterator deferrers=deferredFrom.iterator();
            while (deferrers.hasNext()) {
              WeakReference reference=(WeakReference)deferrers.next();
              InstantiableNamedObj deferrer=(InstantiableNamedObj)reference.get();
              if (deferrer != null) {
                String replacementName=newName;
                if (deferrer.getClassName().startsWith("String_Node_Str")) {
                  replacementName=_current.getFullName();
                }
                deferrer.setClassName(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");
      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;
      if (portName != null) {
        request=new UnlinkRequest(portName,relationName,indexSpec,insideIndexSpec);
      }
 else {
        String relation1Name=(String)_attributes.get("String_Node_Str");
        String relation2Name=(String)_attributes.get("String_Node_Str");
        request=new UnlinkRequest(relation1Name,relation2Name);
      }
      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=previous;
      if (vertex == null) {
        vertex=new Vertex((Relation)_current,vertexName);
        vertex.propagateExistence();
      }
      String value=(String)_attributes.get("String_Node_Str");
      if ((value != null) && !value.equals(previousValue)) {
        vertex.setExpression(value);
        try {
          vertex.propagateValue();
          _paramsToParse.add(vertex);
        }
 catch (        IllegalActionException ex) {
          vertex.setExpression(previousValue);
          throw ex;
        }
      }
      _pushContext();
      _current=vertex;
      _namespace=_DEFAULT_NAMESPACE;
      if (_undoEnabled) {
        _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) {
    exceptionThrown=true;
    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(),_getLineNumber(),_getColumnNumber());
      }
    }
    throw new XmlException("String_Node_Str" + elementName + "String_Node_Str"+ ex.getTargetException(),_currentExternalEntity(),_getLineNumber(),_getColumnNumber(),ex.getTargetException());
  }
catch (  Exception ex) {
    exceptionThrown=true;
    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) {
        if (_toplevel != null) {
          _toplevel.setDeferringChangeRequests(_previousDeferStatus);
          _toplevel.executeChangeRequests();
        }
        throw new XmlException("String_Node_Str",_currentExternalEntity(),_getLineNumber(),_getColumnNumber());
      }
    }
    if (_toplevel != null) {
      _toplevel.setDeferringChangeRequests(_previousDeferStatus);
      _toplevel.executeChangeRequests();
    }
    if (ex instanceof XmlException) {
      throw (XmlException)ex;
    }
 else {
      throw new XmlException("String_Node_Str" + elementName + "String_Node_Str",_currentExternalEntity(),_getLineNumber(),_getColumnNumber(),ex);
    }
  }
 finally {
    _attributes.clear();
    _attributeNameList.clear();
    if (exceptionThrown) {
      if (pushedDeleteRequests) {
        try {
          _deleteRequests=(List)_deleteRequestStack.pop();
        }
 catch (        EmptyStackException ex) {
          _deleteRequests=null;
        }
      }
      if (pushedLinkRequests) {
        try {
          _linkRequests=(List)_linkRequestStack.pop();
        }
 catch (        EmptyStackException ex) {
          _linkRequests=null;
        }
      }
      if (_namespacesPushed) {
        try {
          _namespace=(String)_namespaces.pop();
          _namespaceTranslationTable=(Map)_namespaceTranslations.pop();
        }
 catch (        EmptyStackException ex) {
          _namespace=_DEFAULT_NAMESPACE;
        }
      }
      if (pushedUndoContexts) {
        try {
          _undoContext=(UndoContext)_undoContexts.pop();
        }
 catch (        EmptyStackException ex) {
        }
      }
    }
  }
}