Package org.w3c.dom

Examples of org.w3c.dom.Node.insertBefore()


        if (last != document) {
            final String text = new String(ch, start, length);
            if (lastSibling != null && lastSibling.getNodeType() == Node.TEXT_NODE) {
                ((Text)lastSibling).appendData(text);
            } else if (last == root && nextSibling != null) {
                lastSibling = last.insertBefore(document.createTextNode(text), nextSibling);
            } else {
                lastSibling = last.appendChild(document.createTextNode(text));
            }

        }
View Full Code Here


        Node last = (Node)nodeStk.peek();

        // If the SAX2DOM is created with a non-null next sibling node,
        // insert the result nodes before the next sibling under the root.
        if (last == root && nextSibling != null) {
            last.insertBefore(tmp, nextSibling);
        } else {
            last.appendChild(tmp);
        }

        // Push this node onto stack
View Full Code Here

    public void processingInstruction(String target, String data) {
        final Node last = (Node)nodeStk.peek();
        ProcessingInstruction pi = document.createProcessingInstruction(target, data);
        if (pi != null) {
            if (last == root && nextSibling != null) {
                last.insertBefore(pi, nextSibling);
            } else {
                last.appendChild(pi);
            }

            lastSibling = pi;
View Full Code Here

    public void comment(char[] ch, int start, int length) {
        final Node last = (Node)nodeStk.peek();
        Comment comment = document.createComment(new String(ch, start, length));
        if (comment != null) {
            if (last == root && nextSibling != null) {
                last.insertBefore(comment, nextSibling);
            } else {
                last.appendChild(comment);
            }

            lastSibling = comment;
View Full Code Here

            Node interfaceList = document.getElementsByTagName("InterfaceList").item(0);
            if(interfaceList.getChildNodes().getLength() == 0){
              interfaceList.appendChild(eventInputs);
            }
            else {
              interfaceList.insertBefore(eventInputs, interfaceList.getFirstChild());
            }
          }
          eventInputs.appendChild(eventElement);
        } else if(eventType == EventType.Output){
          Node eventOutputs = document.getElementsByTagName("EventOutputs").item(0);
View Full Code Here

              interfaceList.appendChild(eventOutputs);
            }
            else {
              // If there is no <EventInputs> in <InterfaceList>, <EventOutputs> is the first element
              if(document.getElementsByTagName("EventInputs").item(0) == null){
                interfaceList.insertBefore(eventOutputs, interfaceList.getFirstChild());
              }
              // If there is <EventInputs> in <InterfaceList>, <EventOutputs> is the second element
              else {
                Node eventInputs =
                  interfaceList.replaceChild(eventOutputs, interfaceList.getFirstChild());
View Full Code Here

        else if(variableType == VariableType.Internal){
          Node internalVars = document.getElementsByTagName("InternalVars").item(0);
          if(internalVars == null){
            Node basicFB = document.getElementsByTagName("BasicFB").item(0);
            internalVars = document.createElement("InternalVars");
            basicFB.insertBefore(internalVars, basicFB.getFirstChild());
            //document.insertBefore(internalVars, basicFB);
          }
          internalVars.appendChild(varElement);
        }
      }
View Full Code Here

        }
        Text currentNode = null;
      if (isReadOnly()){
            Text newNode = this.ownerDocument().createTextNode(content);
            if (parent !=null) { // check if node in the tree               
                parent.insertBefore(newNode, this);
                parent.removeChild(this);
                currentNode = newNode;
            } else {
                return newNode;
            }
View Full Code Here

      setNodeValue(data.substring(0, offset));

        // insert new text node
        Node parentNode = getParentNode();
      if (parentNode != null) {
        parentNode.insertBefore(newText, nextSibling);
        }

      return newText;

    } // splitText(int):Text
View Full Code Here

                    (fStartContainer.getNodeValue()).substring(0,fStartOffset));
                Node next = fStartContainer.getNextSibling();
                if (next != null) {
                    Node parent = fStartContainer.getParentNode();
                    if (parent !=  null) {
                        parent.insertBefore(newNode, next);
                        parent.insertBefore(cloneCurrent, next);
                    }
                } else {
                    Node parent = fStartContainer.getParentNode();
                    if (parent != null) {
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.