Package nu.xom

Examples of nu.xom.ParentNode.indexOf()


//            throw new MultipleParentException(
//            "XQuery morpher result sequence must not contain multiple identical nodes");
          }
          boolean isRoot = parent instanceof Document && node instanceof Element;
          if (!isInitialized) {
            if (!(node instanceof Attribute)) position = parent.indexOf(node);
            if (!isRoot) node.detach();
            isInitialized = true;
          }
         
          if (result instanceof Attribute) {
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

                    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

                    // 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

    * @param node The reference node.
    * @return The next Sibling, or null.
    */ 
  public static Node getNextSibling(Node node) {
    ParentNode parent = node.getParent();
    int i = parent.indexOf(node);
    if (i+1 >= parent.getChildCount()) return null;
    return parent.getChild(i+1);
  }
 
  /**Gets the first next sibling of a given node whose tagname matches the given string.
View Full Code Here

    * @param node The reference node.
    * @return The previous Sibling, or null.
    */
  public static Node getPreviousSibling(Node node) {
    ParentNode parent = node.getParent();
    int i = parent.indexOf(node);
    if (i==0) return null;
    return parent.getChild(i-1);
  }
 
 
View Full Code Here

     * @param node The reference node.
     * @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 node The reference node.
     * @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

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.