Package nu.xom

Examples of nu.xom.ParentNode


            for (int i = 0; i < nodes.size(); i++) {
                result.append(nodes.get(i));         
            }           
        }
        else {
            ParentNode parent = (ParentNode) parents.get(parents.size()-1);
            for (int i = 0; i < nodes.size(); i++) {
                Node node = nodes.get(i);
                if (node instanceof Attribute) {
                    ((Element) parent).addAttribute((Attribute) node);
                }
                else {
                    parent.appendChild(node);
                }           
            }
        }
       
    }
View Full Code Here


      replaceByChildren(node, node)
    }
  }
 
  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);
    }
    parent.removeChild(toReplace);           
  }
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

  /**
   * Retrieve the nearest ancestor element that has the given attribute,
   * or null if no such ancestor exists.
   */
  public static Element getAncestorWithAttribute(Element element, String attrName) {
    ParentNode parent = element.getParent();
    if(parent!=null && parent instanceof Element) {     
      Element eparent = (Element)parent;
      if(eparent.getAttribute(attrName)!=null){
        return eparent;
      }
View Full Code Here

  /**
   * Retrieve the nearest ancestor element that has the given name,
   * or null if no such ancestor exists.
   */
  public static Element getAncestor(Element element, String localName, String namespaceURI) {
    ParentNode parent = element.getParent();
    if(parent!=null && parent instanceof Element) {     
      Element eparent = (Element)parent;
      if(eparent.getLocalName().equals(localName)
          && eparent.getNamespaceURI().equals(namespaceURI)){
        return eparent;
View Full Code Here

  public static void replace(Element toReplace, Element with) {
    toReplace.getParent().replaceChild(toReplace, with);   
  }

  public static boolean hasAncestor(Element element, Element possibleAncestor) {
    ParentNode parent = element.getParent();
    if(parent!=null && parent instanceof Element) {     
      Element eparent = (Element)parent;
      if(eparent == possibleAncestor)  {       
        return true;
      }
View Full Code Here

            throw new FunctionCallException(pe);
        }
    }

    public Object getDocumentNode(Object o) {
        ParentNode parent = null;
        if (o instanceof ParentNode) {
            parent = (ParentNode)o;
        } else if (o instanceof Node) {
            parent = ((Node)o).getParent();
        }
        return parent.getDocument();
    }
View Full Code Here

        if (! isElement(o)) {
            return JaxenConstants.EMPTY_ITERATOR;
        }
        Map nsMap = new HashMap();
        Element elt = (Element)o;
        ParentNode parent = elt;
       
        while (parent instanceof Element) {
            elt = (Element)parent;
            String uri    = elt.getNamespaceURI();
            String prefix = elt.getNamespacePrefix();
View Full Code Here

TOP

Related Classes of nu.xom.ParentNode

Copyright © 2018 www.massapicom. 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.