Java Reference
In-Depth Information
JAXBContext context = JAXBContext.newInstance(classes);
context.generateSchema(resolver);
out.println("All done.");
}
}
/**
* Extends the resolver.
*/
class MySchemaOutputResolver extends SchemaOutputResolver {
private File output;
public MySchemaOutputResolver(String dir, String fileName){
output = new File(dir, fileName);
}
public Result createOutput(String namespaceUri,
String suggestedFileName) throws IOException {
return new StreamResult(output);
}
}
Running this file produces an identical result to the one achieved by generating the schema
with schemagen and JAXB annotations earlier, but with the benefit of being able to use it
more flexibly at runtime.
Search WWH ::




Custom Search