private Node getNodeToBeReplaced ( Node parametersNode ) { Node toBeReplaced = null ; int responseCount = 0 ; NodeList childNodes = parametersNode . getChildNodes ( ) ; if ( childNodes != null ) { for ( int j = 0 ; j < childNodes . getLength ( ) ; j ++ ) { Node childNode = childNodes . item ( j ) ; String name = childNode . getLocalName ( ) ; if ( "simpleResponse" . equals ( name ) || "response" . equals ( name ) ) { responseCount ++ ; if ( "response" . equals ( name ) ) { //This is the node that will need to be replaced with a copy with a localName of "simpleResponse" toBeReplaced = childNode ; } } //If responseCount>1 This implies that both a simpleResponse and response have //been defined - this is allowed by the xsd, but makes no sense if ( responseCount > 1 ) { throw new IllegalArgumentException ( "Only one of either simpleResponse or response should define the response type" ) ; } } } return toBeReplaced ; }
Also ensures only one of the two has been defined