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:edu.internet2.middleware.shibboleth.common.config.attribute.filtering.BaseFilterBeanDefinitionParser.java

/**
 * Generates an ID for a filter engine component. If the given localId is null a random one will be generated.
 * /*from   w  w w .  j a v a  2  s  .  co m*/
 * @param configElement component configuration element
 * @param componentNamespace namespace for the component
 * @param localId local id or null
 * 
 * @return unique ID for the componenent
 */
protected String getQualifiedId(Element configElement, String componentNamespace, String localId) {
    Element afpgElement = configElement.getOwnerDocument().getDocumentElement();
    String policyGroupId = DatatypeHelper.safeTrimOrNullString(afpgElement.getAttributeNS(null, "id"));

    StringBuilder qualifiedId = new StringBuilder();
    qualifiedId.append("/");
    qualifiedId.append(AttributeFilterPolicyGroupBeanDefinitionParser.ELEMENT_NAME.getLocalPart());
    qualifiedId.append(":");
    qualifiedId.append(policyGroupId);
    if (!DatatypeHelper.isEmpty(componentNamespace)) {
        qualifiedId.append("/");
        qualifiedId.append(componentNamespace);
        qualifiedId.append(":");

        if (DatatypeHelper.isEmpty(localId)) {
            qualifiedId.append(idGen.generateIdentifier());
        } else {
            qualifiedId.append(localId);
        }
    }

    return qualifiedId.toString();
}

From source file:DOMTreeWalkerTreeModel.java

/**
 * Create a TreeModel for a TreeWalker that returns the specified element
 * and all of its descendant nodes./* ww w  .jav  a 2  s  .co  m*/
 */
public DOMTreeWalkerTreeModel(Element element) {
    DocumentTraversal dt = (DocumentTraversal) element.getOwnerDocument();
    walker = dt.createTreeWalker(element, NodeFilter.SHOW_ALL, null, false);
}

From source file:com.bstek.dorado.idesupport.robot.EntityDataTypeReflectionRobot.java

private Element createPropertyElement(Element parentElement, String propertyName) {
    Document document = parentElement.getOwnerDocument();
    Element propertyElement = document.createElement("Property");
    propertyElement.setAttribute(XmlConstants.ATTRIBUTE_NAME, propertyName);
    parentElement.appendChild(propertyElement);
    return propertyElement;
}

From source file:com.tonbeller.wcf.tree.TreeHandler.java

public void render(RequestContext context) throws Exception {
    super.render(context);
    Element parent = getElement();
    DomUtils.removeChildElements(parent);
    Element child = tree.render(context, parent.getOwnerDocument());
    parent.appendChild(child);//  w  w w  .ja v  a 2  s.  co  m
}

From source file:de.betterform.xml.dom.DOMUtil.java

/**
 * creates and appends an Element with given name to given parent and adds value as TextNode to new Element
 * @param parent the parent Element to append to
 * @param elementName the name of the Element to create
 * @param value the TextNode value of the newly created Element
 * /*from   ww w. j  a va2  s  .com*/
 */
public static void appendElement(Element parent, String elementName, String value) {
    Element e = parent.getOwnerDocument().createElement(elementName);
    DOMUtil.setElementValue(e, value);
    parent.appendChild(e);
}

From source file:com.tonbeller.wcf.table.TableHandler.java

public void render(RequestContext context) throws Exception {
    super.render(context);
    Element parent = getElement();
    DomUtils.removeChildElements(parent);
    Element child = table.render(context, parent.getOwnerDocument());
    parent.appendChild(child);/* w w w. j  av  a  2 s  .  co  m*/
}

From source file:com.netspective.sparx.util.xml.XmlSource.java

public static Element getOrCreateElement(Element parent, String name) {
    NodeList nl = parent.getElementsByTagName(name);
    if (nl.getLength() == 0) {
        Element newElem = parent.getOwnerDocument().createElement(name);
        parent.appendChild(newElem);/*from w  w w  .j  av  a 2  s . c o m*/
        return newElem;
    } else
        return (Element) nl.item(0);
}

From source file:de.betterform.connector.ConnectorFactory.java

protected XFormsProcessorImpl getProcessor(Element e) {

    Object o = e.getOwnerDocument().getDocumentElement().getUserData("");
    if (o instanceof Container) {
        return ((Container) o).getProcessor();
    }/*  www.  java 2 s.co  m*/
    return null;
}

From source file:de.betterform.xml.dom.DOMUtil.java

/**
 * Appends the specified value as a text node to the element. If the
 * value is <code>null</code>, the element's first child node will be
 * removed.//from  w w w  . ja v  a  2s  .  c  om
 *
 * @param element the element.
 * @param value   the element's value.
 */
public static void setElementValue(Element element, String value) {
    Node child = element.getFirstChild();

    if (value != null) {
        if (child == null) {
            child = element.getOwnerDocument().createTextNode("");
            element.appendChild(child);
        }

        child.setNodeValue(value);
    } else {
        if (child != null) {
            element.removeChild(child);
        }
    }
}

From source file:com.msopentech.odatajclient.engine.data.impl.v3.AtomSerializer.java

private void setLinks(final Element entry, final List<AtomLink> links) throws ParserConfigurationException {
    for (AtomLink link : links) {
        final Element linkElem = entry.getOwnerDocument().createElement(ODataConstants.ATOM_ELEM_LINK);

        linkElem.setAttribute(ODataConstants.ATTR_REL, link.getRel());
        linkElem.setAttribute(ODataConstants.ATTR_TITLE, link.getTitle());
        linkElem.setAttribute(ODataConstants.ATTR_HREF, link.getHref());

        if (StringUtils.isNotBlank(link.getType())) {
            linkElem.setAttribute(ODataConstants.ATTR_TYPE, link.getType());
        }/*from  www. ja v a2s.  c  o  m*/

        if (link.getInlineEntry() != null || link.getInlineFeed() != null) {
            final Element inline = entry.getOwnerDocument().createElement(ODataConstants.ATOM_ELEM_INLINE);
            linkElem.appendChild(inline);

            if (link.getInlineEntry() != null) {
                inline.appendChild(
                        entry.getOwnerDocument().importNode(entry((AtomEntry) link.getInlineEntry()), true));
            }
            if (link.getInlineFeed() != null) {
                inline.appendChild(
                        entry.getOwnerDocument().importNode(feed((AtomFeed) link.getInlineFeed()), true));
            }
        }

        entry.appendChild(linkElem);
    }
}