public boolean isNamespaceNode ( Node n ) { if ( Node . ATTRIBUTE_NODE == n . getNodeType ( ) ) { String attrName = n . getNodeName ( ) ; return ( attrName . startsWith ( "xmlns:" ) || attrName . equals ( "xmlns" ) ) ; } return false ; }
Test whether the given node is a namespace decl node . In DOM Level 2 this can be done in a namespace - aware manner but in Level 1 DOMs it has to be done by testing the node name .