Example usage for org.w3c.dom Node isDefaultNamespace

List of usage examples for org.w3c.dom Node isDefaultNamespace

Introduction

In this page you can find the example usage for org.w3c.dom Node isDefaultNamespace.

Prototype

public boolean isDefaultNamespace(String namespaceURI);

Source Link

Document

This method checks if the specified namespaceURI is the default namespace or not.

Usage

From source file:com.marklogic.dom.ElementImpl.java

/** {@inheritDoc} */
@Override/*from   ww w . j  a  v a 2  s.  c  o m*/
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;
}

From source file:com.marklogic.dom.NodeImpl.java

/**
 * {@inheritDoc}/*www.  j av a2s.  com*/
 * <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);
}

From source file:org.sakaiproject.importer.impl.CommonCartridgeFileParser.java

private boolean enclosingDocumentContainsNamespaceDeclaration(Node node, String nameSpaceURI) {
    return node.isDefaultNamespace(CC_NAMESPACE_URI);
}

From source file:org.sakaiproject.importer.impl.LBCommonCartridgeFileParser.java

private boolean enclosingDocumentContainsNamespaceDeclaration(Node node, String nameSpaceURI) {
    return node.isDefaultNamespace(nameSpaceURI);
}