private void doElement(Node received, Node source,
            XmlMessageValidationContext validationContext, NamespaceContext namespaceContext, TestContext context) {

        doElementNameValidation(received, source);

        doElementNamespaceValidation(received, source);

        //check if element is ignored either by xpath or by ignore placeholder in source message
        if (XmlValidationUtils.isElementIgnored(source, received, validationContext.getIgnoreExpressions(), namespaceContext)) {
            return;
        }

        //work on attributes
        if (log.isDebugEnabled()) {
            log.debug("Validating attributes for element: " + received.getLocalName());
        }
        NamedNodeMap receivedAttr = received.getAttributes();
        NamedNodeMap sourceAttr = source.getAttributes();

        Assert.isTrue(countAttributes(receivedAttr) == countAttributes(sourceAttr),
                ValidationUtils.buildValueMismatchErrorMessage("Number of attributes not equal for element '"
                        + received.getLocalName() + "'", countAttributes(sourceAttr), countAttributes(receivedAttr)));

        for (int i = 0; i < receivedAttr.getLength(); i++) {
            doAttribute(received, receivedAttr.item(i), source, validationContext, namespaceContext, context);
        }

        //check if validation matcher on element is specified
        if (isValidationMatcherExpression(source)) {
            ValidationMatcherUtils.resolveValidationMatcher(source.getNodeName(),
                    received.getFirstChild().getNodeValue().trim(),
                    source.getFirstChild().getNodeValue().trim(),
                    context);
            return;
        }

        doText((Element) received, (Element) source);

        //work on child nodes
        List<Element> receivedChildElements = DomUtils.getChildElements((Element) received);
        List<Element> sourceChildElements = DomUtils.getChildElements((Element) source);

        Assert.isTrue(receivedChildElements.size() == sourceChildElements.size(),
                ValidationUtils.buildValueMismatchErrorMessage("Number of child elements not equal for element '"
                    + received.getLocalName() + "'", sourceChildElements.size(), receivedChildElements.size()));

        for (int i = 0; i < receivedChildElements.size(); i++) {
            this.validateXmlTree(receivedChildElements.get(i), sourceChildElements.get(i),
                    validationContext, namespaceContext, context);
        }

        if (log.isDebugEnabled()) {
            log.debug("Validation successful for element: " + received.getLocalName() +
                    " (" + received.getNamespaceURI() + ")");
        }
    }
private void doElement ( Node received , Node source , XmlMessageValidationContext validationContext , NamespaceContext namespaceContext , TestContext context ) { doElementNameValidation ( received , source ) ; doElementNamespaceValidation ( received , source ) ; if ( XmlValidationUtils . isElementIgnored ( source , received , validationContext . getIgnoreExpressions ( ) , namespaceContext ) ) { return ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Validating attributes for element: " + received . getLocalName ( ) ) ; } NamedNodeMap receivedAttr = received . getAttributes ( ) ; NamedNodeMap sourceAttr = source . getAttributes ( ) ; Assert . isTrue ( countAttributes ( receivedAttr ) == countAttributes ( sourceAttr ) , ValidationUtils . buildValueMismatchErrorMessage ( "Number of attributes not equal for element '" + received . getLocalName ( ) + "'" , countAttributes ( sourceAttr ) , countAttributes ( receivedAttr ) ) ) ; for ( int i = 0 ; i < receivedAttr . getLength ( ) ; i ++ ) { doAttribute ( received , receivedAttr . item ( i ) , source , validationContext , namespaceContext , context ) ; } if ( isValidationMatcherExpression ( source ) ) { ValidationMatcherUtils . resolveValidationMatcher ( source . getNodeName ( ) , received . getFirstChild ( ) . getNodeValue ( ) . trim ( ) , source . getFirstChild ( ) . getNodeValue ( ) . trim ( ) , context ) ; return ; } doText ( ( Element ) received , ( Element ) source ) ; List < Element > receivedChildElements = DomUtils . getChildElements ( ( Element ) received ) ; List < Element > sourceChildElements = DomUtils . getChildElements ( ( Element ) source ) ; Assert . isTrue ( receivedChildElements . size ( ) == sourceChildElements . size ( ) , ValidationUtils . buildValueMismatchErrorMessage ( "Number of child elements not equal for element '" + received . getLocalName ( ) + "'" , sourceChildElements . size ( ) , receivedChildElements . size ( ) ) ) ; for ( int i = 0 ; i < receivedChildElements . size ( ) ; i ++ ) { this . validateXmlTree ( receivedChildElements . get ( i ) , sourceChildElements . get ( i ) , validationContext , namespaceContext , context ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Validation successful for element: " + received . getLocalName ( ) + " (" + received . getNamespaceURI ( ) + ")" ) ; } }
Handle element node.

@param received
@param source
@param validationContext