private static Attr findMatchingAttr ( final List < Attr > attrs , final Attr attrToMatch ) { final boolean hasNs = attrToMatch . getNamespaceURI ( ) != null ; final String nsToMatch = attrToMatch . getNamespaceURI ( ) ; final String nameToMatch = hasNs ? attrToMatch . getLocalName ( ) : attrToMatch . getName ( ) ; for ( Attr a : attrs ) { if ( ( ( ! hasNs && a . getNamespaceURI ( ) == null ) || ( hasNs && nsToMatch . equals ( a . getNamespaceURI ( ) ) ) ) && ( ( hasNs && nameToMatch . equals ( a . getLocalName ( ) ) ) || ( ! hasNs && nameToMatch . equals ( a . getName ( ) ) ) ) ) { return a ; } } return null ; }
Find the attribute with the same namespace and local name as a given attribute in a list of attributes .