class XsdStubDescriptorValidator implements StubDescriptorValidator {

    @Override
    public void validate(final Document document, final Schema schema) {
        try {
            Validator validator = schema.newValidator();
            validator.validate(domSourceFactory.newDOMSource(document));
        } catch (Exception e) {
            throw new DescriptorValidationFailedException("Validation of stub descriptor failed - XSD validation failed.", e);
        }

    }

}