/** * Handle attribute node during validation. * * @param receivedElement * @param receivedAttribute * @param sourceElement * @param validationContext */ private void doAttribute( Node receivedElement, Node receivedAttribute, Node sourceElement, XmlMessageValidationContext validationContext, NamespaceContext namespaceContext, TestContext context) { if (receivedAttribute.getNodeName().startsWith(XMLConstants.XMLNS_ATTRIBUTE)) { return; } String receivedAttributeName = receivedAttribute.getLocalName(); if (log.isDebugEnabled()) { log.debug( "Validating attribute: " + receivedAttributeName + " (" + receivedAttribute.getNamespaceURI() + ")"); } NamedNodeMap sourceAttributes = sourceElement.getAttributes(); Node sourceAttribute = sourceAttributes.getNamedItemNS(receivedAttribute.getNamespaceURI(), receivedAttributeName); Assert.isTrue( sourceAttribute != null, "Attribute validation failed for element '" + receivedElement.getLocalName() + "', unknown attribute " + receivedAttributeName + " (" + receivedAttribute.getNamespaceURI() + ")"); if (XmlValidationUtils.isAttributeIgnored( receivedElement, receivedAttribute, sourceAttribute, validationContext.getIgnoreExpressions(), namespaceContext)) { return; } String receivedValue = receivedAttribute.getNodeValue(); String sourceValue = sourceAttribute.getNodeValue(); if (isValidationMatcherExpression(sourceAttribute)) { ValidationMatcherUtils.resolveValidationMatcher( sourceAttribute.getNodeName(), receivedAttribute.getNodeValue().trim(), sourceAttribute.getNodeValue().trim(), context); } else if (receivedValue.contains(":") && sourceValue.contains(":")) { doNamespaceQualifiedAttributeValidation( receivedElement, receivedAttribute, sourceElement, sourceAttribute); } else { Assert.isTrue( receivedValue.equals(sourceValue), ValidationUtils.buildValueMismatchErrorMessage( "Values not equal for attribute '" + receivedAttributeName + "'", sourceValue, receivedValue)); } if (log.isDebugEnabled()) { log.debug("Attribute '" + receivedAttributeName + "'='" + receivedValue + "': OK"); } }