private void sameElementNode ( ) throws XMLStreamException , TTException { // Update variables. mInsert = EInsert . NOINSERT ; mDelete = EDelete . NODELETE ; mInserted = false ; mInsertedEndTag = false ; mRemovedNode = false ; // Check if last node reached. // checkIfLastNode(false); // Skip whitespace events. skipWhitespaces ( mReader ) ; // Move transaction. final ElementNode element = ( ElementNode ) mWtx . getNode ( ) ; if ( element . hasFirstChild ( ) ) { /* * If next event needs to be inserted, it has to be inserted at the * top of the subtree, as first child. */ mInsert = EInsert . ATTOP ; mWtx . moveTo ( ( ( ITreeStructData ) mWtx . getNode ( ) ) . getFirstChildKey ( ) ) ; if ( mReader . peek ( ) . getEventType ( ) == XMLStreamConstants . END_ELEMENT ) { /* * Next event is an end tag, so the current child element, where * the transaction currently is located needs to be removed. */ mKeyMatches = - 1 ; mDelete = EDelete . ATBOTTOM ; deleteNode ( ) ; } // } else if (mReader.peek().getEventType() == // XMLStreamConstants.END_ELEMENT // && // !mReader.peek().asEndElement().getName().equals(mWtx.getQNameOfCurrentNode())) // { // /* // * Node must be removed when next end tag doesn't match the // current name and it has no children. // */ // mKeyMatches = -1; // mDelete = EDelete.ATBOTTOM; // deleteNode(); } else if ( mReader . peek ( ) . getEventType ( ) != XMLStreamConstants . END_ELEMENT ) { /* * Treetank transaction can't find a child node, but StAX parser * finds one, so it must be inserted as a first child of the current * node. */ mInsert = EInsert . ATTOP ; mEmptyElement = true ; } else { mInsert = EInsert . ATMIDDLEBOTTOM ; } }
Nodes match thus update stack and move cursor to first child if it is not a leaf node .