public static boolean isElementIgnored ( final Node received , Set < String > ignoreExpressions , NamespaceContext namespaceContext ) { if ( CollectionUtils . isEmpty ( ignoreExpressions ) ) { return false ; } /** This is the faster version, but then the ignoreValue name must be * the full path name like: Numbers.NumberItem.AreaCode */ if ( ignoreExpressions . contains ( XMLUtils . getNodesPathName ( received ) ) ) { return true ; } /** This is the slower version, but here the ignoreValues can be * the short path name like only: AreaCode * * If there are more nodes with the same short name, * the first one will match, eg. if there are: * Numbers1.NumberItem.AreaCode * Numbers2.NumberItem.AreaCode * And ignoreValues contains just: AreaCode * the only first Node: Numbers1.NumberItem.AreaCode will be ignored. */ for ( String expression : ignoreExpressions ) { if ( received == XMLUtils . findNodeByName ( received . getOwnerDocument ( ) , expression ) ) { return true ; } } /** This is the XPath version using XPath expressions in * ignoreValues to identify nodes to be ignored */ for ( String expression : ignoreExpressions ) { if ( XPathUtils . isXPathExpression ( expression ) ) { NodeList foundNodes = XPathUtils . evaluateAsNodeList ( received . getOwnerDocument ( ) , expression , namespaceContext ) ; if ( foundNodes != null ) { for ( int i = 0 ; i < foundNodes . getLength ( ) ; i ++ ) { if ( foundNodes . item ( i ) != null && foundNodes . item ( i ) . isSameNode ( received ) ) { return true ; } } } } } return false ; }
Checks whether the node is ignored by node path expression or xpath expression .