Java Code Examples for org.dom4j.Element.getNamespace()

The following are Jave code examples for showing how to use getNamespace() of the org.dom4j.Element class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ats-framework   File: XmlNode.java   View Source Code Vote up 5 votes
public XmlNode( XmlNode parent, Element node ) {

        this.node = node;

        Namespace nodeNamespace = node.getNamespace();
        if (nodeNamespace != null && !StringUtils.isNullOrEmpty(nodeNamespace.getPrefix())) {
            this.name = nodeNamespace.getPrefix() + ":" + node.getName();
        } else {
            this.name = node.getName();
        }

        this.attributes = new TreeMap<>();
        for (int i = 0; i < node.attributes().size(); i++) {
            Attribute att = node.attribute(i);
            this.attributes.put(att.getName(), att.getValue());
        }

        this.value = this.node.getTextTrim();

        this.parent = parent;

        this.children = new ArrayList<>();
        List<Element> childrenElements = this.node.elements();
        for (Element child : childrenElements) {
            if (child.getNodeType() == Node.ELEMENT_NODE) {
                this.children.add(new XmlNode(this, child));
            }
        }
    }
 
Example 2
Project: joai-project   File: NamespaceRegistry.java   View Source Code Vote up 5 votes
/**
 *  Gets the namespace attribute of the NamespaceRegistry class
 *
 * @param  doc  NOT YET DOCUMENTED
 * @return      The namespace value
 */
public static Namespace getNamespace(Document doc) {
	Element root = doc.getRootElement();

	Namespace ns = root.getNamespace();
	if (ns == null)
		prtln("namespace not found");

	return ns;
}