try {
InputSource is = new InputSource(in);
SchemaFactory schf = SchemaFactory.lookup(SchemaFactory.NAMESPACE_SCHEMATRON);
Schema sch = schf.compileSchema(is);
Validator validator = sch.newValidator();
// set preprocessor parameters
if (phase!=null) {
validator.setProperty(Validator.PROPERTY_PHASE, phase);
}
ZTestBean tbean = new ZTestBean();
// measure validation speed
long time = System.currentTimeMillis();
List vs = null;
for (int i = 0; i<count; i++) {
// perform validation
vs = validator.validate(tbean);
}
time = System.currentTimeMillis()-time;
System.out.println("Validation performed "+count+
" times for a total of "+time+" ms");
System.out.println("Avarage validation time is "+(time/count)+