Package nu.xom

Examples of nu.xom.ParentNode.insertChild()


          System.out.println("child:" + sentenceContent.get(i).toString());
        }*/
        //sentenceElement.removeChildren();
       
        Element newSentence = new Element("s");
        parent.insertChild(newSentence, childIndex);
        Attribute sidAttr = new Attribute("sid", sentid);
        newSentence.addAttribute(sidAttr);       
        newSentence.appendChild(annotationElement);
        //System.out.println(newSentence.toString());
      }
View Full Code Here


                    // or document.
                    if (parent instanceof Element) {
                        int position = parent.indexOf(element);
                        for (int i = 0; i < replacements.size(); i++) {
                            Node child = replacements.get(i);
                            parent.insertChild(child, position+i);
                        }
                        element.detach();
                    }
                    else // root element needs special treatment
                        // I am assuming here that it is not possible
View Full Code Here

                        Node replacement = replacements.get(j);
                        if (replacement instanceof Attribute) {
                            ((Element) parent).addAttribute((Attribute) replacement);
                        }
                        else {
                            parent.insertChild(replacement, parent.indexOf(element));
                        }  
                    }                   
                    parent.removeChild(element);
                }
                else {
View Full Code Here

    int pos = parent.indexOf(toReplace);
    Elements toInsert = addChildren.getChildElements();
    for (int j = 0; j < toInsert.size(); j++) {
      Element child = toInsert.get(j);
      child.detach();
      parent.insertChild(child, ++pos);
    }
    parent.removeChild(toReplace);           
  }
 
  public static void replace(Node replaced, List<Node> replacements) {
View Full Code Here

    int pos = parent.indexOf(replaced);
    parent.removeChild(replaced);
    if(pos==0) pos = -1;
    for (Node node : replacements) {     
      node.detach();   
      parent.insertChild(node, ++pos);     
   
  }
 
  /**
   * Append the child nodes of source to destination, copying them from the source.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.