Java Utililty Methods XML Node Namespace

List of utility methods to do XML Node Namespace

Description

The list of methods to do XML Node Namespace are organized into topic(s).

Method

booleanhasNamespaceURI(@Nullable final Node aNode, @Nullable final String sNamespaceURI)
has Namespace URI
final String sNSURI = aNode == null ? null : aNode.getNamespaceURI();
return sNSURI != null && sNSURI.equals(sNamespaceURI);
booleanisAppropriateElement(Node iNode, String iNodeName, String iNamespace)
This method determins if a node in the DOM Tree (iNode) is the node we are looking for.
Logger.getLogger("org.adl.util.debug.samplerte").entering("DOMTreeUtility", "isAppropriateElement()");
Logger.getLogger("org.adl.util.debug.samplerte").finest("Input Parent Node: " + iNode.getLocalName());
Logger.getLogger("org.adl.util.debug.samplerte").finest("Input Node being searched for: " + iNodeName);
Logger.getLogger("org.adl.util.debug.samplerte")
        .finest("Input Namespace of node being searched for: " + iNamespace);
boolean result = false;
if (iNode.getNodeType() == Node.ATTRIBUTE_NODE) {
    if (iNode.getNamespaceURI() == null) {
...
booleanisAppropriateElement(Node iNode, String iNodeName, String iNamespace)
This method determins if a node in the DOM Tree (iNode) is the node we are looking for.
boolean result = false;
if (iNode.getNodeType() == Node.ATTRIBUTE_NODE) {
    if (iNode.getNamespaceURI() == null) {
        String parentsNamespace = ((Attr) iNode).getOwnerElement().getNamespaceURI();
        if ((iNode.getLocalName().equals(iNodeName)) && (parentsNamespace.equals(iNamespace))) {
            result = true;
    } else {
...
booleanisInNamespace(Node node, String namespace)
Determines if the given Node belongs to the namespace with the given String name.
return namespace.equals(node.getNamespaceURI());
booleanisInNamespace(Node node, String namespace)
Determines if the given Node belongs to the namespace with the given String name.
return namespace.equals(node.getNamespaceURI());
booleanisNamespace(Node node)
is Namespace
final short nodeType = node.getNodeType();
if (nodeType == Node.ATTRIBUTE_NODE) {
    final String namespaceURI = node.getNamespaceURI();
    return XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI);
return false;
booleanisNamespaceElement(Node node, String namespace)
Determines if the given Node is an Element and is in the given String namespace.
if (node == null) {
    return false;
} else if (node.getNodeType() != Node.ELEMENT_NODE) {
    return false;
} else if (namespace != null && !namespace.equals(node.getNamespaceURI())) {
    return false;
} else {
    return true;
...
booleanisNamespaceElement(Node node, String namespace)
Determines if the given Node is an Element and is in the given String namespace.
if (node == null) {
    return false;
} else if (node.getNodeType() != Node.ELEMENT_NODE) {
    return false;
} else if (namespace != null && !namespace.equals(node.getNamespaceURI())) {
    return false;
} else {
    return true;
...
booleanisNonDefaultNamespace(Node node)
is Non Default Namespace
return (isNamespace(node) && !"xmlns".equals(node.getNodeName()));
booleanisSameNamespace(Node node, String namespace)
is Same Namespace
String prefix = getPrefix(node.getNodeName());
return hasNamespace(node, prefix, namespace);