Examples of ParentNode


Examples of nu.xom.ParentNode

       
        while (true) {
           Attribute lang = element.getAttribute(
             "lang", "http://www.w3.org/XML/1998/namespace");
           if (lang != null) return lang.getValue();
           ParentNode parent = element.getParent();
           if (parent == null) return "";
           else if (parent instanceof Document) return "";
           else element = (Element) parent;
        }
       
View Full Code Here

Examples of nu.xom.ParentNode

            }
       
            for (int i = 0; i < elementSchemeData.size(); i++) {
                String currentData = (String) (elementSchemeData.get(i));
                int[] keys = new int[0];
                ParentNode current = doc;
                if (currentData.indexOf('/') == -1) {
                    // raw id in element like element(f2)
                    try {
                        new Element(currentData);
                    }
View Full Code Here

Examples of nu.xom.ParentNode

            else {
                if (end) {
                    if (current == element) break;
                }
                end = false;
                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++;
                    current = parent.getChild(index);
                }
            }
        } 
       
        return null;
View Full Code Here

Examples of nu.xom.ParentNode

    *
    * @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);
  }
View Full Code Here

Examples of nu.xom.ParentNode

    *
    * @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

Examples of nu.xom.ParentNode

     *
     * @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);
  }
View Full Code Here

Examples of nu.xom.ParentNode

     *
     * @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);
  }
View Full Code Here

Examples of nu.xom.ParentNode

   * instances of a Text node next to another Text node are created.
   *
   * @param elem The element to remove from the document.
   */
  public static void removeElementPreservingText(Element elem) {
    ParentNode parent = elem.getParent();
    /* Put fingers on relevant nodes */
    Node previous = XOMTools.getPreviousSibling(elem);
    Node next = XOMTools.getNextSibling(elem);
    int index = elem.getParent().indexOf(elem);
    if(elem.getChildCount() > 0) {
      /* Put fingers on relevant inner nodes */
      Node contentsFirst = elem.getChild(0);
      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

Examples of nu.xom.ParentNode

  public void removeProcessingInstructions() {
    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

Examples of nu.xom.ParentNode

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