ProfileParser profileParser = new ProfileParser(false);
RuntimeProfile profile = profileParser.parseClasspath("ca/uhn/hl7v2/examples/profiles/ADT_A31.xml");
// Create a conformance validator, and validate
DefaultValidator validator = new DefaultValidator();
HL7Exception[] exceptions = validator.validate(validMessage, profile.getMessage());
System.out.println("Found " + exceptions.length + " problems");
for (int i = 0; i < exceptions.length; i++) {
HL7Exception exception = exceptions[i];
System.out.println(" * " + exception.getClass().getSimpleName() + " - " + exception.getMessage());