Java Code Examples for org.w3c.dom.Node#isDefaultNamespace()

The following examples show how to use org.w3c.dom.Node#isDefaultNamespace() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/** {@inheritDoc} */
@Override
public boolean isDefaultNamespace(String namespaceURI) {
    String namespace = this.getNamespaceURI();
    String prefix = this.getPrefix();

    if (prefix == null || prefix.length() == 0) {
        if (namespaceURI == null) {
            return (namespace == namespaceURI);
        }
        return namespaceURI.equals(namespace);
    }
    if (this.hasAttributes()) {
        Attr attr = this.getAttributeNodeNS(
            "http://www.w3.org/2000/xmlns/", "xmlns");
        if (attr != null) {
            String value = attr.getNodeValue();
            if (namespaceURI == null) {
                return (namespace == value);
            }
            return namespaceURI.equals(value);
        }
    }

    Node ancestor = getParentNode();
    if (ancestor != null) {
        short type = ancestor.getNodeType();
        if (type == NodeKind.ELEM) {
            return ancestor.isDefaultNamespace(namespaceURI);
        }
        // otherwise, current node is root already
    }
    return false;
}
 
Example 2
Source Project: marklogic-contentpump   File: NodeImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>
 * Not supported for namespace declaration. Overrided by DocumentImpl and
 * ElementImpl
 * </p>
 */
public boolean isDefaultNamespace(String namespaceURI) {
    int type = getNodeType();
    if (type == NodeKind.ATTR) {
        if (this instanceof AttrImpl == false) {
            // ns decl
            throw new UnsupportedOperationException();
        }
    }
    Node p = getParentNode();
    return p.isDefaultNamespace(namespaceURI);
}
 
Example 3
private boolean enclosingDocumentContainsNamespaceDeclaration(Node node, String nameSpaceURI) {
    return node.isDefaultNamespace(nameSpaceURI);
}
 
Example 4
private boolean enclosingDocumentContainsNamespaceDeclaration(Node node, String nameSpaceURI) {
	return node.isDefaultNamespace(CC_NAMESPACE_URI);
}
 
Example 5
private boolean enclosingDocumentContainsNamespaceDeclaration(Node node, String nameSpaceURI) {
    return node.isDefaultNamespace(nameSpaceURI);
}
 
Example 6
private boolean enclosingDocumentContainsNamespaceDeclaration(Node node, String nameSpaceURI) {
	return node.isDefaultNamespace(CC_NAMESPACE_URI);
}