Example usage for org.w3c.dom Element getOwnerDocument

List of usage examples for org.w3c.dom Element getOwnerDocument

Introduction

In this page you can find the example usage for org.w3c.dom Element getOwnerDocument.

Prototype

public Document getOwnerDocument();

Source Link

Document

The Document object associated with this node.

Usage

From source file:Main.java

public static void addText(Element element, String text) {
    element.appendChild(element.getOwnerDocument().createTextNode(text));
}

From source file:Main.java

public static Element addElement(Element root, String name) {
    Element newElement = root.getOwnerDocument().createElement(name);
    root.appendChild(newElement);/* w ww.  j av  a2s .  co m*/
    return newElement;
}

From source file:Utils.java

/**
 * Add Text object to an Element.//from   ww  w. ja v a  2  s. c  o  m
 * @param element the containing element
 * @param text the text to add
 */
public static void addText(Element element, String text) {
    element.appendChild(element.getOwnerDocument().createTextNode(text));
}

From source file:Main.java

/**
 * Returns true if the element's containing document 
 * @param elem//  w  w w. ja va  2  s . c  om
 * @return
 */
public static boolean isInDitaDocument(Element elem) {
    Element root = elem.getOwnerDocument().getDocumentElement();
    Element cand = root;
    if (cand.getTagName().equals(DITA_ELEM_TAGNAME)) {
        // FIXME: This a little weak but unlikely to return false positives.         
        return true;
    }
    return root.hasAttributeNS(DITA_ARCH_NS, DITA_ARCH_VERSION_ATTNAME);
}

From source file:Main.java

static public Element createElement(Element parent, String tagName) {
    Element tag = parent.getOwnerDocument().createElement(tagName);
    parent.appendChild(tag);/* w w w.  jav a  2s .c  o m*/
    return tag;
}

From source file:Main.java

public static Element AddChild(Element parent, String nodename) {
    Element childnode = parent.getOwnerDocument().createElement(nodename);
    parent.appendChild(childnode);//  w  w  w . ja  v  a 2s.c om
    return childnode;
}

From source file:Main.java

public static final void setComment(Element element, String data) {
    Comment comm = element.getOwnerDocument().createComment(data != null ? data : ""); //$NON-NLS-1$
    element.getParentNode().insertBefore(comm, element);
}

From source file:Main.java

/**
 *//*  w w  w . j a  va2s  .co  m*/
public static void appendComment(Element element, String comment) {
    Node commentNode = element.getOwnerDocument().createComment(comment);
    element.appendChild(commentNode);
}

From source file:Utils.java

/**
 * Add an entity to a specified Element.
 *    (eg <code>DomUtils.addEntity(element, "nbsp");</code>)
 * @param element the containing element
 * @param entity the entity to add/*from   w w w.  j  a v a 2s. c o  m*/
 */
public static void addEntity(Element element, String entity) {
    element.appendChild(element.getOwnerDocument().createEntityReference(entity));
}

From source file:Main.java

public static synchronized void appedIndent(Element e, int indent) {
    Document doc = e.getOwnerDocument();
    if (indent == 0) {
        e.appendChild(doc.createTextNode("\n"));
    }/*from   w  ww  .  ja v  a  2  s  .c  o m*/
    for (int i = 0; i < indent; i++) {
        if (i == 0) {
            e.appendChild(doc.createTextNode("\n\t"));
        } else {
            e.appendChild(doc.createTextNode("\t"));
        }
    }
}