Package nu.xom

Examples of nu.xom.ParentNode.indexOf()


    procInstructions = new ArrayList<ProcessingInstruction>();
    Nodes piNodes = pubXMLDoc.getRootElement().query(".//processing-instruction()");
    for(int i=0;i<piNodes.size();i++) {
      ProcessingInstruction pi = (ProcessingInstruction)piNodes.get(i);
      ParentNode piParent = pi.getParent();
      int index = piParent.indexOf(pi);
      Element e = new Element("pi-proxy");
      e.addAttribute(new Attribute("pinumber", Integer.toString(i)));
      pi.detach();
      piParent.insertChild(e, index);
      procInstructions.add(pi);
View Full Code Here


  public void replaceProcessingInstructions(Document newPubDoc) {
    Nodes proxyNodes = newPubDoc.query("//pi-proxy");
    for(int i=0;i<proxyNodes.size();i++) {
      Element e = (Element)proxyNodes.get(i);
      ParentNode eParent = e.getParent();
      int index = eParent.indexOf(e);
      int pin = Integer.parseInt(e.getAttributeValue("pinumber"));
      ProcessingInstruction pi = procInstructions.get(pin);
      e.detach();
      eParent.insertChild(pi, index);
    }       
View Full Code Here

        Elements sentenceChildren = sentenceElement.getChildElements();
        for(int j = 0; j < sentenceChildren.size(); j++) {
          //System.out.println(sentenceChildren.get(j));
        }
        ParentNode parent = sentenceElement.getParent();
        int childIndex = parent.indexOf(sentenceElement);
        sentenceElement.detach();
       
        //Elements sentenceContent = sentenceElement.getChildElements();
        //System.out.println("content of sentence: " + sentenceContent);
        ArrayList<Attribute> attArray = new ArrayList<Attribute>();
View Full Code Here

                    // adjust the type of exception thrown. This is only
                    // relevant if I add support for the xpointer scheme
                    // since otherwise you can only point at one element
                    // 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();
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

                ParentNode parent = current.getParent();
                if (parent.getChildCount() - 1 == index) {
                    current = parent;
                    if (current != element) {
                        parent = current.getParent();
                        index = parent.indexOf(current);
                    }
                    end = true;
                }
                else {
                    index++;
View Full Code Here

                    ParentNode parent = current.getParent();
                    if (parent.getChildCount() - 1 == index) {
                        current = parent;
                        if (current != element) {
                            parent = current.getParent();
                            index = parent.indexOf(current);
                        }
                        end = true;
                    }
                    else {
                        index++;
View Full Code Here

    }
  }
 
  public static void replaceByChildren(Element toReplace, Element addChildren) {
    ParentNode parent = toReplace.getParent();
    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);
View Full Code Here

    parent.removeChild(toReplace);           
  }
 
  public static void replace(Node replaced, List<Node> replacements) {
    ParentNode parent = replaced.getParent();
    int pos = parent.indexOf(replaced);
    parent.removeChild(replaced);
    if(pos==0) pos = -1;
    for (Node node : replacements) {     
      node.detach();   
      parent.insertChild(node, ++pos);     
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.