rem: newTocElement.insertBefore(text, newTocFrame); 
add: newTocLink.appendChild(text); 
context: function addToToc(root, tocFrame){  var i;  var newTocFrame = tocFrame;  var newTocElement = null;  for (i=0; i < searchTags.length; i++) {    if (root.tagName == searchTags[i]) {      newTocElement = document.createElement(tocTags[i]);      newTocElement.setAttribute("xml:link", "simple");      newTocElement.setAttribute("href", "#"+ root.getAttribute("id"));      newTocElement.setAttribute("show", "replace");      if (i < searchTags.length-1) {        // XXX DOM Level 1 does not have a way to specify the namespace        // of an element at creation time. The W3C DOM Working Group is         // considering such a mechanism for DOM Level 2. In the interim,         // we've created the one used below. It will be removed in favor         //of the standard version in Level 2.        var img = document.createElementWithNameSpace("img", "http://www.w3.org/TR/REC-html40");        img.src = "minus.gif";        img.onmouseup = toggleDisplay;        newTocElement.appendChild(img);         newTocFrame = document.createElementWithNameSpace("div", "http://www.w3.org/TR/REC-html40");        newTocElement.appendChild(newTocFrame);      }      else {        newTocFrame = null;      }      tocFrame.appendChild(newTocElement);      break;    }  }  for (i=0; i < root.childNodes.length; i++) {    var child = root.childNodes[i];    if (child.nodeType == Node.ELEMENT_NODE) {      if ((newTocElement != null) && (child.tagName == "title")) {        var text = child.firstChild.cloneNode(true);        newTocElement.insertBefore(text, newTocFrame);      }      else {        addToToc(child, newTocFrame);      }    }  }}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/75db23b24d68ff243df82c37493d1c03f315945a/toc.js/buggy/content/xml/tests/toc/toc.js