this.codeModel = _codeModel;
this.errorReceiver = new ErrorReceiverFilter(er);
}
private Model load() {
Model grammar;
if(!sanityCheck())
return null;
try {
switch (opt.getSchemaLanguage()) {
case DTD :
// TODO: make sure that bindFiles,size()<=1
InputSource bindFile = null;
if (opt.getBindFiles().length > 0)
bindFile = opt.getBindFiles()[0];
// if there is no binding file, make a dummy one.
if (bindFile == null) {
// if no binding information is specified, provide a default
bindFile =
new InputSource(
new StringReader(
"<?xml version='1.0'?><xml-java-binding-schema><options package='"
+ (opt.defaultPackage==null?"generated":opt.defaultPackage)
+ "'/></xml-java-binding-schema>"));
}
checkTooManySchemaErrors();
grammar = loadDTD(opt.getGrammars()[0], bindFile );
break;
case RELAXNG :
checkTooManySchemaErrors();
grammar = loadRELAXNG();
break;
case RELAXNG_COMPACT :
checkTooManySchemaErrors();
grammar = loadRELAXNGCompact();
break;
case WSDL:
grammar = annotateXMLSchema( loadWSDL() );
break;
case XMLSCHEMA:
grammar = annotateXMLSchema( loadXMLSchema() );
break;
default :
throw new AssertionError(); // assertion failed
}
if (errorReceiver.hadError()) {
grammar = null;
} else {
grammar.setPackageLevelAnnotations(opt.packageLevelAnnotations);
}
return grammar;
} catch (SAXException e) {