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 Element addElement(Element parent, Element childElement) {
    Node childNode = parent.getOwnerDocument().importNode(childElement, true);
    parent.appendChild(childNode);//ww w.  j  a va 2  s .c  o  m
    return parent;
}

From source file:Main.java

public static Element createElement(Element element, String tagName, String text) {
    Document doc = element.getOwnerDocument();
    Element child = doc.createElement(tagName);
    if (text != null)
        child.setTextContent(text);// ww  w . j ava 2s . c o m
    element.appendChild(child);
    return child;
}

From source file:Main.java

/** Appends a new empty child element with the given namespace and name. */
public static Element appendElementNS(Element parent, String namespaceURI, String localName) {
    Element ret = parent.getOwnerDocument().createElementNS(namespaceURI, localName);
    parent.appendChild(ret);// w w w.j  a v  a2 s  . c  om
    return ret;
}

From source file:Main.java

/**
 * Append an foreign DOM element as child to an existing DOM element.
 * /*from  ww w  .java 2  s.  c om*/
 * @param parent the parent DOM element
 * @param child the child element to append to the parent
 */
public static void append(Element parent, Element child) {
    Node newChild = parent.getOwnerDocument().adoptNode(child);
    if (newChild == null) {
        newChild = parent.getOwnerDocument().importNode(child, true);
    }
    parent.appendChild(newChild);
}

From source file:Main.java

/**
 * Appends another element as a child element.
 *
 * @param parent the parent element//from w w w . j  a  va  2 s .  co  m
 * @param child the child element to append
 */
public static void appendElement(Element parent, Element child) {
    Node tmp = parent.getOwnerDocument().importNode(child, true);
    parent.appendChild(tmp);
}

From source file:Main.java

public static void createElement(Element parent, String elementName, String text) {
    Document doc = parent.getOwnerDocument();
    Element id = doc.createElement(elementName);
    id.setTextContent(text);// ww w.  j  av a 2  s  .  co  m
    parent.appendChild(id);
}

From source file:Main.java

/**
 * Returns true if the element appears to be a map or within a map.
 * @param elem/*ww  w . j  a v a2s .c o  m*/
 * @return True or false
 */
public static boolean isDitaMap(Element elem) {
    Element root = elem.getOwnerDocument().getDocumentElement();
    if (root != null && isInDitaDocument(root)) {
        return isDitaType(root, DITA_MAP_TYPE);
    }
    return false;
}

From source file:Main.java

public static void flagDocumentAsCorrected(Element element) {
    Document doc = element.getOwnerDocument();
    if (doc != null) {
        doc.setUserData("autoCorrected", "true", null);
    }/*from  w w  w .ja v  a2s .  c o m*/
}

From source file:Main.java

static public void booleanContentTag(Element parent, String tagName, boolean content) {
    Element tag = parent.getOwnerDocument().createElement(tagName);
    if (content)/*w ww  .  ja  v a2 s  .  c o m*/
        tag.setTextContent("1");
    else
        tag.setTextContent("0");
    parent.appendChild(tag);
}

From source file:Main.java

public static void addChildElement(Element element, String child_ele_name, String text) {
    Document doc = element.getOwnerDocument();
    Element sub_element = createLeafElement(doc, child_ele_name, text);
    element.appendChild(sub_element);/*w ww  .  j a v  a 2  s  .c  om*/
}