Package nu.xom

Examples of nu.xom.ParentNode.insertChild()


          } else {
            if (isRoot && result instanceof Element) {
              parent.replaceChild(node, result);
            } else {
              result.detach();
              parent.insertChild(result, position);
            }
            position++;
          }
        }
      }
View Full Code Here


                node.detach();
            }
            else {
                Element dummy = new Element("dummy");
                ParentNode parent = node.getParent();
                parent.insertChild(dummy, parent.indexOf(node));
                node.detach();
                dummy.appendChild(node);
            }
            return;
        }
View Full Code Here

            }
            parent.removeChild(position);
            while (element.getChildCount() > 0) {
                Node child = element.getChild(0);
                element.removeChild(0);
                parent.insertChild(child, position);
                position++;
                if (child instanceof Element) strip((Element) child);
            }    
           
        }
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

     * @param newNode The new node to insert.
     */
  public static void insertBefore(Node node, Node newNode) {
    ParentNode parent = node.getParent();
    int i = parent.indexOf(node);
    parent.insertChild(newNode, i);
  }

  /**Inserts a node so that it occurs after a reference node. The new node
     * must not currently have a parent.
     *
 
View Full Code Here

     * @param newNode The new node to insert.
     */
  public static void insertAfter(Node node, Node newNode) {
    ParentNode parent = node.getParent();
    int i = parent.indexOf(node);
    parent.insertChild(newNode, i+1);
  }
  /**Makes a semi-shallow copy of an element, copying the element,
     * the namespace and the attribute, but no other child nodes.
     *
 
View Full Code Here

      Node contentsLast = elem.getChild(elem.getChildCount()-1);
      /* Transfer inner nodes to parent */
      while(elem.getChildCount() > 0) {
        Node nn = elem.getChild(0);
        nn.detach();
        parent.insertChild(nn, index);
        index++;
      }
      /* Perform Text surgery */
      if((previous instanceof Text) && (contentsFirst instanceof Text)) {
        ((Text)previous).setValue(previous.getValue() + contentsFirst.getValue());
View Full Code Here

      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);
    }   
  }
 
  public void replaceProcessingInstructions(Document newPubDoc) {
View Full Code Here

      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);
    }       
  }
 
  public Document getSciXML() {
    return sciXMLDoc;
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.