private void removeUndefinedOperations ( Node target , Node extensions ) throws Exception { final XPathFactory factory = XPathFactory . newInstance ( ) ; final NodeList nodes = ( NodeList ) factory . newXPath ( ) . evaluate ( "//operation" , target , XPathConstants . NODESET ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; i ++ ) { final Node targetNode = nodes . item ( i ) ; String nameBasedXpath = DomUtils . getNameBasedXPath ( targetNode , true ) ; log . debug ( "Checking operation: " + nameBasedXpath ) ; final NodeList targetNodes = ( NodeList ) factory . newXPath ( ) . evaluate ( nameBasedXpath , extensions , XPathConstants . NODESET ) ; if ( targetNodes . getLength ( ) == 0 ) { // This operation is not defined in the extensions doc log . debug ( "Ignoring IDL defined operation: " + getAttribute ( targetNode , "name" ) ) ; targetNode . getParentNode ( ) . removeChild ( targetNode ) ; } } }
Cycle through the target Node and remove any operations not defined in the extensions document .