Program: 75597
Project: 75597
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");
      _checkForNull(className,"String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      String source=(String)_attributes.get("String_Node_Str");
      NamedObj newEntity=_createEntity(className,entityName,source);
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=newEntity.toplevel();
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      newEntity.getMoMLInfo().elementName="String_Node_Str";
      newEntity.getMoMLInfo().className=newEntity.getFullName();
      newEntity.getMoMLInfo().superclass=className;
      _current=newEntity;
      _namespace=_DEFAULT_NAMESPACE;
    }
 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;
      NamedObj container=_current;
      _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 (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=newEntity.toplevel();
        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._propagating=_propagating;
        _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");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      int countArgs=0;
      if (insertAtSpec != null) {
        countArgs++;
      }
      if (insertInsideAtSpec != null) {
        countArgs++;
      }
      if (relationName != null) {
        countArgs++;
      }
      if (countArgs == 0) {
        throw new XmlException("String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
      if (insertAtSpec != null && insertInsideAtSpec != null) {
        throw new XmlException("String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
      CompositeEntity context=(CompositeEntity)_current;
      ComponentPort port=_getPort(portName,context);
      int origNumOutsideLinks=port.numLinks();
      int origNumInsideLinks=port.numInsideLinks();
      ComponentRelation relation=null;
      if (relationName != null) {
        Relation tmpRelation=context.getRelation(relationName);
        _checkForNull(tmpRelation,"String_Node_Str" + relationName + "String_Node_Str"+ context.getFullName());
        relation=(ComponentRelation)tmpRelation;
      }
      int insertAt=-1;
      if (insertAtSpec != null) {
        insertAt=Integer.parseInt(insertAtSpec);
      }
      int insertInsideAt=-1;
      if (insertInsideAtSpec != null) {
        insertInsideAt=Integer.parseInt(insertInsideAtSpec);
      }
      if (insertAtSpec != null) {
        port.insertLink(insertAt,relation);
      }
 else       if (insertInsideAtSpec != null) {
        port.insertInsideLink(insertInsideAt,relation);
      }
 else {
        port.link(relation);
      }
      if (_undoEnabled && _undoContext.isUndoable()) {
        if (relation == null) {
          if (insertAt != -1) {
            if (port.numLinks() != origNumOutsideLinks) {
              _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ insertAtSpec+ "String_Node_Str");
            }
          }
 else {
            if (port.numInsideLinks() != origNumInsideLinks) {
              _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ insertInsideAtSpec+ "String_Node_Str");
            }
          }
        }
 else {
          if (port.numInsideLinks() != origNumInsideLinks) {
            if (insertInsideAt == -1) {
              insertInsideAt=port.numInsideLinks() - 1;
            }
            _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ insertInsideAt+ "String_Node_Str");
          }
 else           if (port.numLinks() != origNumOutsideLinks) {
            if (insertAt == -1) {
              insertAt=port.numLinks() - 1;
            }
            _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ insertAt+ "String_Node_Str");
          }
 else {
          }
        }
      }
      _recordLink(context,portName,relationName,insertAtSpec);
    }
 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);
        }
        _recordNewObject(container,port);
      }
      _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;
          ioport.setOutput(direction.equals("String_Node_Str") || direction.equals("String_Node_Str"));
          ioport.setInput(direction.equals("String_Node_Str") || direction.equals("String_Node_Str"));
        }
      }
    }
 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");
      boolean isIOPort=(_current instanceof IOPort);
      if (propertyName.equals("String_Node_Str") && isIOPort) {
        boolean previousValue=false;
        IOPort currentIOPort=(IOPort)_current;
        previousValue=currentIOPort.isMultiport();
        if (value == null || value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setMultiport(true);
        }
 else         if (value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setMultiport(false);
        }
        _pushContext();
        _current=(Attribute)_current.getAttribute(propertyName);
        _namespace=_DEFAULT_NAMESPACE;
        if (_undoEnabled && _undoContext.isUndoable()) {
          _undoContext.appendUndoMoML("String_Node_Str" + propertyName + "String_Node_Str");
          _undoContext.appendUndoMoML(previousValue + "String_Node_Str");
          _undoContext.setChildrenUndoable(true);
          _undoContext.appendClosingUndoMoML("String_Node_Str");
        }
      }
 else       if (propertyName.equals("String_Node_Str") && isIOPort) {
        boolean previousValue=false;
        IOPort currentIOPort=(IOPort)_current;
        previousValue=currentIOPort.isOutput();
        if (value == null || value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setOutput(true);
        }
 else         if (value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setOutput(false);
        }
        _pushContext();
        _current=(Attribute)_current.getAttribute(propertyName);
        _namespace=_DEFAULT_NAMESPACE;
        if (_undoEnabled && _undoContext.isUndoable()) {
          _undoContext.appendUndoMoML("String_Node_Str" + propertyName + "String_Node_Str");
          _undoContext.appendUndoMoML(previousValue + "String_Node_Str");
          _undoContext.setChildrenUndoable(true);
          _undoContext.appendClosingUndoMoML("String_Node_Str");
        }
      }
 else       if (propertyName.equals("String_Node_Str") && isIOPort) {
        boolean previousValue=false;
        IOPort currentIOPort=(IOPort)_current;
        previousValue=currentIOPort.isInput();
        if (value == null || value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setInput(true);
        }
 else         if (value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setInput(false);
        }
        _pushContext();
        _current=(Attribute)_current.getAttribute(propertyName);
        _namespace=_DEFAULT_NAMESPACE;
        if (_undoEnabled && _undoContext.isUndoable()) {
          _undoContext.appendUndoMoML("String_Node_Str" + propertyName + "String_Node_Str");
          _undoContext.appendUndoMoML(previousValue + "String_Node_Str");
          _undoContext.setChildrenUndoable(true);
          _undoContext.appendClosingUndoMoML("String_Node_Str");
        }
      }
 else {
        NamedObj property=(Attribute)_current.getAttribute(propertyName);
        Class newClass=null;
        if (className != null) {
          try {
            newClass=Class.forName(className,true,_classLoader);
          }
 catch (          NoClassDefFoundError ex) {
            throw new XmlException("String_Node_Str" + className + "String_Node_Str"+ KernelException.stackTraceToString(ex),_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
          }
        }
        boolean createdNew=false;
        boolean previouslyExisted=(property != null);
        String oldClassName=null;
        String oldValue=null;
        if (previouslyExisted) {
          oldClassName=property.getClass().getName();
          if (property instanceof Settable) {
            Settable settable=(Settable)property;
            oldValue=settable.getExpression();
          }
        }
        if (property == null || (newClass != null && !newClass.isInstance(property))) {
          try {
            if (newClass == null) {
              newClass=Attribute.class;
            }
            Object[] arguments=new Object[2];
            arguments[0]=_current;
            arguments[1]=propertyName;
            property=_createInstance(newClass,arguments);
            if (value != null) {
              if (!(property instanceof Settable)) {
                throw new XmlException("String_Node_Str" + "String_Node_Str" + propertyName + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
              }
              Settable settable=(Settable)property;
              settable.setExpression(value);
              _paramsToParse.add(property);
            }
            createdNew=true;
          }
 catch (          NameDuplicationException ex) {
          }
        }
        if (!createdNew) {
          if (value != null) {
            if (!(property instanceof Settable)) {
              throw new XmlException("String_Node_Str" + "String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
            }
            Settable settable=(Settable)property;
            settable.setExpression(value);
            _paramsToParse.add(property);
          }
        }
        _pushContext();
        _current=property;
        _namespace=_DEFAULT_NAMESPACE;
        if (_undoEnabled && _undoContext.isUndoable()) {
          if (!previouslyExisted) {
            _undoContext.appendUndoMoML("String_Node_Str" + propertyName + "String_Node_Str");
            _undoContext.setChildrenUndoable(false);
          }
 else {
            _undoContext.appendUndoMoML("String_Node_Str" + property.getName() + "String_Node_Str");
            _undoContext.appendUndoMoML("String_Node_Str" + oldClassName + "String_Node_Str");
            if (oldValue != null) {
              _undoContext.appendUndoMoML("String_Node_Str" + oldValue + "String_Node_Str");
            }
            _undoContext.appendUndoMoML("String_Node_Str");
            _undoContext.appendClosingUndoMoML("String_Node_Str");
            _undoContext.setChildrenUndoable(true);
          }
        }
      }
    }
 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;
        _recordNewObject(_current,newRelation);
        _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();
        _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) {
          }
        }
      }
    }
 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");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      CompositeEntity context=(CompositeEntity)_current;
      ComponentPort port=_getPort(portName,context);
      int countArgs=0;
      if (indexSpec != null)       countArgs++;
      if (insideIndexSpec != null)       countArgs++;
      if (relationName != null)       countArgs++;
      if (countArgs != 1) {
        throw new XmlException("String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
      CompositeEntity container=(CompositeEntity)_current;
      if (relationName != null) {
        Relation tmpRelation=context.getRelation(relationName);
        _checkForNull(tmpRelation,"String_Node_Str" + relationName + "String_Node_Str"+ context.getFullName());
        ComponentRelation relation=(ComponentRelation)tmpRelation;
        if (_undoEnabled && _undoContext.isUndoable()) {
          ArrayList filter=new ArrayList(2);
          filter.add(relation);
          filter.add(port);
          String replicaLinkMoML=container.exportLinks(0,filter);
          _undoContext.appendUndoMoML(replicaLinkMoML);
        }
        port.unlink(relation);
      }
 else       if (indexSpec != null) {
        int index=Integer.parseInt(indexSpec);
        if (_undoEnabled && _undoContext.isUndoable()) {
          List linkedRelations=port.linkedRelationList();
          Relation r=(Relation)linkedRelations.get(index);
          _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ indexSpec+ "String_Node_Str");
          if (r != null) {
            _undoContext.appendUndoMoML("String_Node_Str" + r.getName() + "String_Node_Str");
          }
          _undoContext.appendUndoMoML("String_Node_Str");
        }
        port.unlink(index);
      }
 else {
        int index=Integer.parseInt(insideIndexSpec);
        if (_undoEnabled && _undoContext.isUndoable()) {
          List linkedRelations=port.insideRelationList();
          Relation r=(Relation)linkedRelations.get(index);
          _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ index+ "String_Node_Str");
          if (r != null) {
            _undoContext.appendUndoMoML("String_Node_Str" + r.getName() + "String_Node_Str");
          }
          _undoContext.appendUndoMoML("String_Node_Str");
        }
        port.unlinkInside(index);
      }
      if (_undoEnabled && _undoContext.isUndoable()) {
        _undoContext.setChildrenUndoable(false);
      }
      _recordUnlink(context,portName,relationName,indexSpec,insideIndexSpec);
    }
 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;
    }
    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");
      _checkForNull(className,"String_Node_Str");
      String entityName=(String)_attributes.get("String_Node_Str");
      _checkForNull(entityName,"String_Node_Str");
      String source=(String)_attributes.get("String_Node_Str");
      NamedObj newEntity=_createEntity(className,entityName,source);
      if (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=newEntity.toplevel();
        if (_xmlFile != null) {
          URIAttribute attribute=new URIAttribute(_toplevel,"String_Node_Str");
          attribute.setURL(_xmlFile);
        }
      }
      newEntity.getMoMLInfo().elementName="String_Node_Str";
      newEntity.getMoMLInfo().className=newEntity.getFullName();
      newEntity.getMoMLInfo().superclass=className;
      _current=newEntity;
      _namespace=_DEFAULT_NAMESPACE;
    }
 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;
      NamedObj container=_current;
      _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 (_current != null) {
        _pushContext();
      }
 else       if (_toplevel == null) {
        _toplevel=newEntity.toplevel();
        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._propagating=_propagating;
        _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");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      int countArgs=0;
      if (insertAtSpec != null) {
        countArgs++;
      }
      if (insertInsideAtSpec != null) {
        countArgs++;
      }
      if (relationName != null) {
        countArgs++;
      }
      if (countArgs == 0) {
        throw new XmlException("String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
      if (insertAtSpec != null && insertInsideAtSpec != null) {
        throw new XmlException("String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
      CompositeEntity context=(CompositeEntity)_current;
      ComponentPort port=_getPort(portName,context);
      int origNumOutsideLinks=port.numLinks();
      int origNumInsideLinks=port.numInsideLinks();
      ComponentRelation relation=null;
      if (relationName != null) {
        Relation tmpRelation=context.getRelation(relationName);
        _checkForNull(tmpRelation,"String_Node_Str" + relationName + "String_Node_Str"+ context.getFullName());
        relation=(ComponentRelation)tmpRelation;
      }
      int insertAt=-1;
      if (insertAtSpec != null) {
        insertAt=Integer.parseInt(insertAtSpec);
      }
      int insertInsideAt=-1;
      if (insertInsideAtSpec != null) {
        insertInsideAt=Integer.parseInt(insertInsideAtSpec);
      }
      if (insertAtSpec != null) {
        port.insertLink(insertAt,relation);
      }
 else       if (insertInsideAtSpec != null) {
        port.insertInsideLink(insertInsideAt,relation);
      }
 else {
        port.link(relation);
      }
      if (_undoEnabled && _undoContext.isUndoable()) {
        if (relation == null) {
          if (insertAt != -1) {
            if (port.numLinks() != origNumOutsideLinks) {
              _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ insertAtSpec+ "String_Node_Str");
            }
          }
 else {
            if (port.numInsideLinks() != origNumInsideLinks) {
              _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ insertInsideAtSpec+ "String_Node_Str");
            }
          }
        }
 else {
          if (port.numInsideLinks() != origNumInsideLinks) {
            if (insertInsideAt == -1) {
              insertInsideAt=port.numInsideLinks() - 1;
            }
            _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ insertInsideAt+ "String_Node_Str");
          }
 else           if (port.numLinks() != origNumOutsideLinks) {
            if (insertAt == -1) {
              insertAt=port.numLinks() - 1;
            }
            _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ insertAt+ "String_Node_Str");
          }
 else {
          }
        }
      }
      _recordLink(context,portName,relationName,insertAtSpec);
    }
 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);
        }
        _recordNewObject(container,port);
      }
      _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;
          ioport.setOutput(direction.equals("String_Node_Str") || direction.equals("String_Node_Str"));
          ioport.setInput(direction.equals("String_Node_Str") || direction.equals("String_Node_Str"));
        }
      }
    }
 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");
      boolean isIOPort=(_current instanceof IOPort);
      if (propertyName.equals("String_Node_Str") && isIOPort) {
        boolean previousValue=false;
        IOPort currentIOPort=(IOPort)_current;
        previousValue=currentIOPort.isMultiport();
        if (value == null || value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setMultiport(true);
        }
 else         if (value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setMultiport(false);
        }
        _pushContext();
        _current=(Attribute)_current.getAttribute(propertyName);
        _namespace=_DEFAULT_NAMESPACE;
        if (_undoEnabled && _undoContext.isUndoable()) {
          _undoContext.appendUndoMoML("String_Node_Str" + propertyName + "String_Node_Str");
          _undoContext.appendUndoMoML(previousValue + "String_Node_Str");
          _undoContext.setChildrenUndoable(true);
          _undoContext.appendClosingUndoMoML("String_Node_Str");
        }
      }
 else       if (propertyName.equals("String_Node_Str") && isIOPort) {
        boolean previousValue=false;
        IOPort currentIOPort=(IOPort)_current;
        previousValue=currentIOPort.isOutput();
        if (value == null || value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setOutput(true);
        }
 else         if (value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setOutput(false);
        }
        _pushContext();
        _current=(Attribute)_current.getAttribute(propertyName);
        _namespace=_DEFAULT_NAMESPACE;
        if (_undoEnabled && _undoContext.isUndoable()) {
          _undoContext.appendUndoMoML("String_Node_Str" + propertyName + "String_Node_Str");
          _undoContext.appendUndoMoML(previousValue + "String_Node_Str");
          _undoContext.setChildrenUndoable(true);
          _undoContext.appendClosingUndoMoML("String_Node_Str");
        }
      }
 else       if (propertyName.equals("String_Node_Str") && isIOPort) {
        boolean previousValue=false;
        IOPort currentIOPort=(IOPort)_current;
        previousValue=currentIOPort.isInput();
        if (value == null || value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setInput(true);
        }
 else         if (value.trim().toLowerCase().equals("String_Node_Str")) {
          ((IOPort)_current).setInput(false);
        }
        _pushContext();
        _current=(Attribute)_current.getAttribute(propertyName);
        _namespace=_DEFAULT_NAMESPACE;
        if (_undoEnabled && _undoContext.isUndoable()) {
          _undoContext.appendUndoMoML("String_Node_Str" + propertyName + "String_Node_Str");
          _undoContext.appendUndoMoML(previousValue + "String_Node_Str");
          _undoContext.setChildrenUndoable(true);
          _undoContext.appendClosingUndoMoML("String_Node_Str");
        }
      }
 else {
        NamedObj property=(Attribute)_current.getAttribute(propertyName);
        Class newClass=null;
        if (className != null) {
          try {
            newClass=Class.forName(className,true,_classLoader);
          }
 catch (          NoClassDefFoundError ex) {
            throw new XmlException("String_Node_Str" + className + "String_Node_Str"+ KernelException.stackTraceToString(ex),_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
          }
        }
        boolean createdNew=false;
        boolean previouslyExisted=(property != null);
        String oldClassName=null;
        String oldValue=null;
        if (previouslyExisted) {
          oldClassName=property.getClass().getName();
          if (property instanceof Settable) {
            Settable settable=(Settable)property;
            oldValue=settable.getExpression();
          }
        }
        if (property == null || (newClass != null && !newClass.isInstance(property))) {
          try {
            if (newClass == null) {
              newClass=Attribute.class;
            }
            Object[] arguments=new Object[2];
            arguments[0]=_current;
            arguments[1]=propertyName;
            property=_createInstance(newClass,arguments);
            if (value != null) {
              if (!(property instanceof Settable)) {
                throw new XmlException("String_Node_Str" + "String_Node_Str" + propertyName + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
              }
              Settable settable=(Settable)property;
              settable.setExpression(value);
              _paramsToParse.add(property);
            }
            createdNew=true;
          }
 catch (          NameDuplicationException ex) {
          }
        }
        if (!createdNew) {
          if (value != null) {
            if (!(property instanceof Settable)) {
              throw new XmlException("String_Node_Str" + "String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
            }
            Settable settable=(Settable)property;
            settable.setExpression(value);
            _paramsToParse.add(property);
          }
        }
        _pushContext();
        _current=property;
        _namespace=_DEFAULT_NAMESPACE;
        if (_undoEnabled && _undoContext.isUndoable()) {
          if (!previouslyExisted) {
            _undoContext.appendUndoMoML("String_Node_Str" + propertyName + "String_Node_Str");
            _undoContext.setChildrenUndoable(false);
          }
 else {
            _undoContext.appendUndoMoML("String_Node_Str" + property.getName() + "String_Node_Str");
            _undoContext.appendUndoMoML("String_Node_Str" + oldClassName + "String_Node_Str");
            if (oldValue != null) {
              _undoContext.appendUndoMoML("String_Node_Str" + oldValue + "String_Node_Str");
            }
            _undoContext.appendUndoMoML("String_Node_Str");
            _undoContext.appendClosingUndoMoML("String_Node_Str");
            _undoContext.setChildrenUndoable(true);
          }
        }
      }
    }
 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;
        _recordNewObject(_current,newRelation);
        _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();
        _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) {
          }
        }
      }
    }
 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");
      _checkClass(_current,CompositeEntity.class,"String_Node_Str" + "String_Node_Str" + _current);
      int countArgs=0;
      if (indexSpec != null) {
        countArgs++;
      }
      if (insideIndexSpec != null) {
        countArgs++;
      }
      if (relationName != null) {
        countArgs++;
      }
      if (countArgs != 1) {
        throw new XmlException("String_Node_Str" + "String_Node_Str",_currentExternalEntity(),_parser.getLineNumber(),_parser.getColumnNumber());
      }
      CompositeEntity context=(CompositeEntity)_current;
      ComponentPort port=_getPort(portName,context);
      CompositeEntity container=(CompositeEntity)_current;
      if (relationName != null) {
        Relation tmpRelation=context.getRelation(relationName);
        _checkForNull(tmpRelation,"String_Node_Str" + relationName + "String_Node_Str"+ context.getFullName());
        ComponentRelation relation=(ComponentRelation)tmpRelation;
        if (_undoEnabled && _undoContext.isUndoable()) {
          List linkedRelations=port.linkedRelationList();
          int index=linkedRelations.indexOf(tmpRelation);
          if (index != -1) {
            _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ index+ "String_Node_Str"+ relationName+ "String_Node_Str");
          }
 else {
            List insideLinkedRelations=port.insideRelationList();
            index=insideLinkedRelations.indexOf(tmpRelation);
            _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ index+ "String_Node_Str"+ relationName+ "String_Node_Str");
          }
        }
        port.unlink(relation);
      }
 else       if (indexSpec != null) {
        int index=Integer.parseInt(indexSpec);
        if (_undoEnabled && _undoContext.isUndoable()) {
          List linkedRelations=port.linkedRelationList();
          Relation r=(Relation)linkedRelations.get(index);
          _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ indexSpec+ "String_Node_Str");
          if (r != null) {
            _undoContext.appendUndoMoML("String_Node_Str" + r.getName(context) + "String_Node_Str");
          }
          _undoContext.appendUndoMoML("String_Node_Str");
        }
        port.unlink(index);
      }
 else {
        int index=Integer.parseInt(insideIndexSpec);
        if (_undoEnabled && _undoContext.isUndoable()) {
          List linkedRelations=port.insideRelationList();
          Relation r=(Relation)linkedRelations.get(index);
          _undoContext.appendUndoMoML("String_Node_Str" + portName + "String_Node_Str"+ index+ "String_Node_Str");
          if (r != null) {
            _undoContext.appendUndoMoML("String_Node_Str" + r.getName(context) + "String_Node_Str");
          }
          _undoContext.appendUndoMoML("String_Node_Str");
        }
        port.unlinkInside(index);
      }
      if (_undoEnabled && _undoContext.isUndoable()) {
        _undoContext.setChildrenUndoable(false);
      }
      _recordUnlink(context,portName,relationName,indexSpec,insideIndexSpec);
    }
 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();
}