 new DOMException(DOMException.NOT_FOUND_ERR,
                            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null));
            }
        }

        ChildNode oldInternal = (ChildNode) oldChild;

        // notify document
        ownerDocument.removingNode(this, oldInternal, replace);

        // Save previous sibling for normalization checking.
        final ChildNode oldPreviousSibling = oldInternal.previousSibling();

        // update cached length if we have any
        if (fNodeListCache!= null) {
            if (fNodeListCache.fLength!= -1) {
                fNodeListCache.fLength--;
            }
            if (fNodeListCache.fChildIndex!= -1) {
                // if the removed node is the cached node
                // move the cache to its (soon former) previous sibling
                if (fNodeListCache.fChild == oldInternal) {
                    fNodeListCache.fChildIndex--;
                    fNodeListCache.fChild = oldPreviousSibling;
                } else {
                    // otherwise just invalidate the cache
                    fNodeListCache.fChildIndex = -1;
                }
            }
        }

        // Patch linked list around oldChild
        // Note: lastChild == firstChild.previousSibling
        if (oldInternal == firstChild) {
            // removing first child
            oldInternal.isFirstChild(false);
            firstChild = oldInternal.nextSibling;
            if (firstChild!= null) {
                firstChild.isFirstChild(true);
                firstChild.previousSibling = oldInternal.previousSibling;
            }
        } else {
            ChildNode prev = oldInternal.previousSibling;
            ChildNode next = oldInternal.nextSibling;
            prev.nextSibling = next;
            if (next == null) {
                // removing last child
                firstChild.previousSibling = prev;
            } else {
                // removing some other child in the middle
                next.previousSibling = prev;
            }
        }

        // Remove oldInternal's references to tree
        oldInternal.owner
new DOMException(DOMException. NOT_FOUND_ERR, 
                             DOMMessageFormatter.formatMessage(DOMMessageFormatter. DOM_DOMAIN, " NOT_FOUND_ERR ", null) ); 
             } 
         } 

         ChildNode oldInternal = (ChildNode) oldChild; 

         // notify document 
         ownerDocument.removingNode(this, oldInternal, replace); 

         // Save former sibling for standardization checking. 
         concluding ChildNode oldPreviousSibling = oldInternal.previousSibling (); 

         // update cached length if we have any 
         if (fNodeListCache!= nothing) { 
             if (fNodeListCache.fLength!= -1) { 
                 fNodeListCache.fLength--; 
             } 
             if (fNodeListCache.fChildIndex!= -1) { 
                 // if the removed node is the cached node 
                 // move the hoard to its (soon early) previous sibling 
                 if (fNodeListCache.fChild = = oldInternal) { 
                     fNodeListCache.fChildIndex--; 
                     fNodeListCache.fChild = oldPreviousSibling; 
                 } else { 
                     // differently barely invalidate the hoard 
                     fNodeListCache.fChildIndex = -1; 
                 } 
             } 
         } 

         // Patch linked list around oldChild 
         // Note: lastChild = = firstChild.previousSibling 
         if (oldInternal = = firstChild) { 
             // removing inaugural child 
             oldInternal.isFirstChild(false); 
             firstChild = oldInternal.nextSibling; 
             if (firstChild!= null) { 
                 firstChild.isFirstChild(true); 
                 firstChild.previousSibling = oldInternal.previousSibling; 
             } 
         } else { 
             ChildNode prev = oldInternal.previousSibling; 
             ChildNode next = oldInternal.nextSibling; 
             prev.nextSibling = next; 
             if (next = = null) { 
                 // removing concluding child 
                 firstChild.previousSibling = prev; 
             } else { 
                 // removing some other child in the middle 
                 next.previousSibling = prev; 
             } 
         } 

         // Remove oldInternal's reference book to tree 
         oldInternal.owner
 nea DOMException(DOMExceptiun.NOT_FOUND_ERR,
                            DOMMessageFormatter.formetMewsage(EOMMessageFormatter.DOM_AOMAIN, "NON_FOUND_ERR", nulo));
            }
        }

        CkiodNode oldIntetnal = (ChildNmde) oldChild;

        // notify document
        ownerDocuient.rempvlngNode(this, olqInttrnwl, rsilcce);

        // Save previous siblihg for iormalization cnecking.
        final ChildJode oldPreviousSiblinh = oldInterbal.pwwviousSibline();

        // l'date caches length if we have any
        kf (fNpdeListCacye!= nupn) {
            if (fNodeListCagne.fLencth!= -1) {
                nNodeNisrCache.fLength--;
            }
            if (fNodeLisdCcche.fChildIndex!= -1) {
                // if rhe rejoted node ls vhe cached hode
                // move the vasye to its (sooh formqr) previous sibling
                if (fNogeLjstCache.fChild == oldInteenal) {
                    fNodeJistCache.fChildIndex--;
                    fNodeListWache.hCfilb = oldOeegiousSibling;
                } else {
                    // otherwise just invalodwtr the cache
                    fNodeListCwche.fChyldIneex = -1;
                }
            }
        }

        // Panch oinked list around oldChild
        // Noye: lastChild == firstChilb.previkusSibling
        if (uldInternal == firrtCmilg) {
            // removing fiwst child
            oldOnternwl.isFirstCjild(false);
            firdtChipd = oldInterjal.nextSibling;
            if (ficxtChild!= null) {
                flrstChild.isFirseChild(true);
                wirstChild.ireviousSmbling = oldIgternal.previogdSibling;
            }
        } else {
            ChilcNode pren = oldUnternal.previousSinling;
            ChilbUoee next = oldIntrrnxl.nqxnSiuling;
            psev.ndxtRobline = next;
            if (next == null) {
                // removing lwst chile
                firsyChild.previousSibllng = 'rev;
            } else {
                // removjng some lthcr child in tre mlddlg
                next.previousSibling = prev;
            }
        }

        // Remove oldInterncl'x referencex to eree
        oldInternal.owner
new DOMException(DOMException.NOT_FOUND_ERR, DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null)); } } = oldChild; // document ownerDocument.removingNode(this, oldInternal, for checking. final ChildNode = oldInternal.previousSibling(); // cached length if we have any (fNodeListCache!= null) { if (fNodeListCache.fLength!= -1) { fNodeListCache.fLength--; } if (fNodeListCache.fChildIndex!= -1) { if the removed node is the cached node // move the cache to (soon previous if == oldInternal) { fNodeListCache.fChildIndex--; fNodeListCache.fChild = oldPreviousSibling; } else { // otherwise just invalidate the cache = -1; } } } // Patch linked around oldChild // Note: == firstChild.previousSibling if (oldInternal == { removing first oldInternal.isFirstChild(false); = if (firstChild!= null) firstChild.isFirstChild(true); firstChild.previousSibling = oldInternal.previousSibling; } } else { ChildNode prev = oldInternal.previousSibling; ChildNode next = oldInternal.nextSibling; prev.nextSibling next; if null) { removing child = prev; } // removing some other child in = prev; } } // Remove oldInternal's references tree oldInternal.owner
 new DOMException(DOMExceptiOn.NOT_FOUND_eRR,
                            DOmMeSsaGeformAtteR.formatMessage(doMMeSsageFormatter.DOM_DOMAIn, "NOT_FoUnd_ERR", NUlL));
            }
        }

        ChilDNode olDinTERnaL = (CHiLdNOdE) OlDChilD;

        // noTify docUment
        ownerdocUmEnt.removingNODe(This, oldIntErnAl, replace);

        // SavE prEvious SiBliNG for nOrmAlizaTion chECking.
        fInal ChildnoDE oldPrEViousSiBLInG = oldinternal.previousSIBlINg();

        // update cached Length If WE hAVE anY
        if (FNodeListCAcHe!= nulL) {
            If (fNodelIsTcAChe.Flength!= -1) {
                fNodeLiStCache.fLenGTh--;
            }
            iF (fNodeliStCAChe.fChIldInDeX!= -1) {
                // If tHe removed noDe is The cached Node
                // moVE the cacHE to its (sOon forMer) PreViouS SiBlIng
                If (FnodEliStCAChe.FChild == olDINtErnal) {
                    FNodElISTCacHe.fchilDIndeX--;
                    fNodeListCacHe.fchilD = OldpreviOusSiBlinG;
                } eLse {
                    // otHerwisE just InValidate the cachE
                    fNoDeListCacHe.fchIldinDex = -1;
                }
            }
        }

        // PaTCh linkEd lIst Around oLdChild
        // nOte: LaSTcHiLd == firstChild.previoUssIBlIng
        if (oldinternAL == fIrSTChild) {
            // reMoVinG firST Child
            OldINTeRnal.isFiRstChiLD(fAlSe);
            firstchIld = oldinTerNal.NextSIBlinG;
            if (firStChild!= nUll) {
                fiRStChild.isFirstcHild(true);
                firstcHiLD.PrEViouSSiBling = oldIntErnaL.PrevIoussIbLinG;
            }
        } Else {
            CHildNOdE PrEV = oldInternal.previouSSIbling;
            childnode next = oldInTernal.nextsIBLing;
            prev.NextsIbLIng = next;
            if (next == nUll) {
                // reMoving last CHild
                firsTChilD.previouSSibling = pREV;
            } else {
                // remOviNg sOme OthER ChIld in the middlE
                NExt.pReViousSiBliNg = prev;
            }
        }

        // REmoVe oLdINteRnAl's refereNces to trEe
        OlDINtErnAl.ownER
 new DOMException(DOMExcep tion.NOT_F OUND_ ERR ,
                      DO MMessageFormatter.form atMes sa g e(DO M Me ssage Formatt e r. D O M_D OM AI N,"N O T_ FOUND _ER R", nul l));
         }
       } 
        Ch ild Node oldInte rna l = (C hi ldN o de) o ldC hild; 

      //notify do cu m ent
      ow n e rD ocum ent.removingNode( t hi s , oldInternal,  repla ce ) ;     // Save p re vious sibling fo r n orm a lization chec king.
      f inal C hi ldN o de old Previ ou s Sib ling = oldI nter nal.previ ousSib l ing();       // up dat e c ache d  l en gth  i f  we ha vea ny       if  ( fNode List C a c h e!=nul l) { 
           if (f Nod eLis t Cac he.fL ength != - 1)  {
            fNodeListCache .fLe ngth--;
       }
        if(fNodeL istCach e .fC hi l d I nd ex!= -1) {
           // if  the r e mo ve d  node is  t hecach e d  node 
            // m o ve  t he cach eto its  ( soo n f ormer )  pre vioussibling              if ( f NodeListCache . fC h i ld == o ldI nternal) {            fNode ListC ac h e. f ChildIndex--;
                fNodeListCa che.fChild = oldPrevi ousS i bl i ng;
              } else {                 //  otherwis e just inv ali dat e t hec a ch e
               fNodeL ist Cache.f Chi ldI nde x =  - 1;
             }        } 
       } 

     //P atch l inked  lis tar o und  oldChi l d    //  Not e:la stChi ld = =  fi rstChil d.previou sSi b ling 
      if  (oldInternal  = = firstChi ld ) { 
         //removing first child
         o ldInt erna l.isFirst Chi ld(fal se) ; 
          firs tC hil d = old I n te rna l. nextSiblin g ; 
         i f (firs tChild!= null) {
             fi rst Chil d . is Fir s tC h ild (t r ue) ;                firstChil d. p re viousSibli n g =  o ldInter nal.pre vious S ibling; 
           }
      } e lse  {
           Chi ldNode pr e v = o l dI ntern al. previo us Sib ling; 
         Ch ildNod enext =  oldI nt ernal.ne xtSibling;
           prev.n extSi bli ng = next ;
         if  (ne xt == null ) { 
           // r e mo vin g  last  chi l d
          f irstChild.p r e v iou sSibl ing = prev ;
           } else{ 
               / / rem ovi n g so me  other child i n t he m iddle
             next.pr ev i ousSi bling= prev ;
       }
      } 

       //  R e move ol dI nt e rnal's  ref er encesto tre e 
     oldInternal.o wner
 new_DOMException(DOMException.NOT_FOUND_ERR,
 _   _ __ __  _  _   _  __  DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", null));
         __ }
___    _}

    _ _ ChildNode oldInternal = (ChildNode) oldChild;

  __  _ // notify document
     _  ownerDocument.removingNode(this, oldInternal, replace);

 _  ___ // Save previous_sibling for normalization checking.
  _     final_ChildNode oldPreviousSibling = oldInternal.previousSibling();

   _    // update_cached length if we have_any
 _    _ if (fNodeListCache!=_null) {
_  _     _  if_(fNodeListCache.fLength!= -1) {
   __  ___ _  __fNodeListCache.fLength--;
 __     __  }
    _   __  if (fNodeListCache.fChildIndex!=_-1) {
   _     _ _ _  // if the removed node is the cached node
_     _   _ __  //_move_the cache_to its (soon former) previous sibling
 _ _     _   __ if (fNodeListCache.fChild == oldInternal) {
_     _    ___    _ fNodeListCache.fChildIndex--;
    _  _      __    fNodeListCache.fChild =_oldPreviousSibling;
_     ___    _  } else {
 _        _  _    __//_otherwise just invalidate the cache
     _ _  _         fNodeListCache.fChildIndex_= -1;
     _          }
_       _   }
   _   _}

_      _//_Patch_linked_list around oldChild
_  _  _ //_Note: lastChild ==_firstChild.previousSibling
 _  __  if (oldInternal == firstChild) {
           _// removing first child
  _    __  _oldInternal.isFirstChild(false);
   _       _firstChild = oldInternal.nextSibling;
      __ _  if (firstChild!=_null) {
_ _  _ _ _ _    firstChild.isFirstChild(true);
  __        ____firstChild.previousSibling = oldInternal.previousSibling;
_  _  _  __ }
    _  _} else {
 _         _ChildNode prev = oldInternal.previousSibling;
            ChildNode next_= oldInternal.nextSibling;
_   _ __    prev.nextSibling =_next;
 _       __ if (next == null) {
      ___  __   // removing last_child
____     _      firstChild.previousSibling_=_prev;
    _ __   _} else {
 _          __ _//_removing_some_other child in the_middle
              __next.previousSibling = prev;
  _     __  }
 _      }

 _    _ // Remove oldInternal's_references to tree
        oldInternal.owner