@ Override public Object invokeMethod ( String methodName , Object args ) { // detect namespace declared on the added node like xmlns:foo="http:/foo" Map attributes = findAttributes ( args ) ; for ( Iterator < Map . Entry > iter = attributes . entrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { Map . Entry entry = iter . next ( ) ; String key = String . valueOf ( entry . getKey ( ) ) ; if ( key . startsWith ( "xmlns:" ) ) { String prefix = key . substring ( 6 ) ; String uri = String . valueOf ( entry . getValue ( ) ) ; namespace ( uri , prefix ) ; iter . remove ( ) ; } } return super . invokeMethod ( methodName , args ) ; }
Allow automatic detection of namespace declared in the attributes