Skip to content
Advertisement

Is it possible to generate a XSD from a JAXB-annotated class?

I’ve written a number of classes using JAXB for serialization and I was wondering if there was a way to generate a XSD file for each of these objects based on the annotations. Is there a tool for this?

Something like generate-xsd com/my/package/model/Unit.java would be awesome. Does anything exist to do this?

Advertisement

Answer

Yes, you can use the generateSchema method on JAXBContext:

JavaScript

You leverage an implementation of SchemaOutputResolver to control where the output goes:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement