// so that users won't have to manually exclude interfaces, which is silly.
if(d instanceof ClassDeclaration)
decls.add(new Reference(d,env));
}
J2SJAXBModel model = XJC.createJavaCompiler().bind(decls,Collections.<QName,Reference>emptyMap(),null,env);
if(model==null)
return; // error
try {
model.generateSchema(
new SchemaOutputResolver() {
public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
File file;
OutputStream out;
if(schemaLocations.containsKey(namespaceUri)) {
file = schemaLocations.get(namespaceUri);
if(file==null) return null; // don't generate
out = new FileOutputStream(file);
} else {
// use the default
file = new File(suggestedFileName);
out = env.getFiler().createBinaryFile(Filer.Location.CLASS_TREE,"",file);
file = file.getAbsoluteFile();
}
StreamResult ss = new StreamResult(out);
env.getMessager().printNotice("Writing "+file);
ss.setSystemId(file.toURL().toExternalForm());
return ss;
}
}, errorListener);
if(episodeFile!=null) {
env.getMessager().printNotice("Writing "+episodeFile);
model.generateEpisodeFile(new StreamResult(episodeFile));
}
} catch (IOException e) {
errorListener.error(e.getMessage(),e);
}
}