public Node replaceChild(Node newChild,Node oldChild) throws DOMException {
  if (oldChild == null || oldChild.getParentNode() != this)   return null;
  ElemTemplateElement newChildElem=((ElemTemplateElement)newChild);
  ElemTemplateElement oldChildElem=((ElemTemplateElement)oldChild);
  ElemTemplateElement prev=(ElemTemplateElement)oldChildElem.getPreviousSibling();
  if (null != prev)   prev.m_nextSibling=newChildElem;
  if (m_firstChild == oldChildElem)   m_firstChild=newChildElem;
  newChildElem.m_parentNode=this;
  oldChildElem.m_parentNode=null;
  newChildElem.m_nextSibling=oldChildElem.m_nextSibling;
  oldChildElem.m_nextSibling=null;
  return newChildElem;
}

public Node replaceChild ( Node newChild , Node oldChild ) throws DOMException { if ( oldChild == null || oldChild . getParentNode ( ) != this ) return null ; ElemTemplateElement newChildElem = ( ( ElemTemplateElement ) newChild ) ; ElemTemplateElement oldChildElem = ( ( ElemTemplateElement ) oldChild ) ; ElemTemplateElement prev = ( ElemTemplateElement ) oldChildElem . getPreviousSibling ( ) ; if ( null != prev ) prev . m_nextSibling = newChildElem ; if ( m_firstChild == oldChildElem ) m_firstChild = newChildElem ; newChildElem . m_parentNode = this ; oldChildElem . m_parentNode = null ; newChildElem . m_nextSibling = oldChildElem . m_nextSibling ; oldChildElem . m_nextSibling = null ; return newChildElem ; }
replace the old child with a new child .
