1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
public static void generateXSD(String destDir, String destName, Class<?> classe) {
final File baseDir = new File(destDir);
class MySchemaOutputResolver extends SchemaOutputResolver {
private String fileName;
public MySchemaOutputResolver(String fileName) {
this.fileName = fileName;
}
public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
return new StreamResult(new File(baseDir, this.fileName));
}
}
JAXBContext context;
try {
context = JAXBContext.newInstance(classe);
context.generateSchema(new MySchemaOutputResolver(destName));
} catch (JAXBException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
Partager