ComparisonState compareNodes ( final Node control , final XPathContext controlContext , final Node test , final XPathContext testContext ) { final Iterable < Node > controlChildren = Linqy . filter ( new IterableNodeList ( control . getChildNodes ( ) ) , getNodeFilter ( ) ) ; final Iterable < Node > testChildren = Linqy . filter ( new IterableNodeList ( test . getChildNodes ( ) ) , getNodeFilter ( ) ) ; return compare ( new Comparison ( ComparisonType . NODE_TYPE , control , getXPath ( controlContext ) , control . getNodeType ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getNodeType ( ) , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . NAMESPACE_URI , control , getXPath ( controlContext ) , control . getNamespaceURI ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getNamespaceURI ( ) , getParentXPath ( testContext ) ) ) . andThen ( new Comparison ( ComparisonType . NAMESPACE_PREFIX , control , getXPath ( controlContext ) , control . getPrefix ( ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , test . getPrefix ( ) , getParentXPath ( testContext ) ) ) . andIfTrueThen ( control . getNodeType ( ) != Node . ATTRIBUTE_NODE , new Comparison ( ComparisonType . CHILD_NODELIST_LENGTH , control , getXPath ( controlContext ) , Linqy . count ( controlChildren ) , getParentXPath ( controlContext ) , test , getXPath ( testContext ) , Linqy . count ( testChildren ) , getParentXPath ( testContext ) ) ) . andThen ( new DeferredComparison ( ) { @ Override public ComparisonState apply ( ) { return nodeTypeSpecificComparison ( control , controlContext , test , testContext ) ; } } ) // and finally recurse into children . andIfTrueThen ( control . getNodeType ( ) != Node . ATTRIBUTE_NODE , compareChildren ( controlContext , controlChildren , testContext , testChildren ) ) ; }
Recursively compares two XML nodes .