if(!validate) break;
// check the validity of generated document.
DOM2toSAX2 d2s = new DOM2toSAX2();
Verifier v = new Verifier(
new REDocumentDeclaration(grammar),
debug?
(ErrorHandler)new ErrorHandlerImpl():
(ErrorHandler)new IgnoreErrorHandler() );
d2s.setContentHandler(v);
d2s.traverse(dom);
if( createError && !v.isValid() ) break;
if( !createError && v.isValid() ) break;
// do it again
if( retry++ == 100 ) {
out.println("unable to generate a proper instance.");
return -1;