tags:

views:

26

answers:

1

Using JAXB I can create an XSD using code like:

JAXBContext ctx = JAXBContext.newInstance(classes);
ctx.generateSchema(new MySchemaOutputResolver());

That makes a goods XSD describing the structure of all the JAXB objects in the list of classes I pass in, however, I can't figure out how to add other types of XSD restrictions like minOccurs, maxOccurs, pattern, etc.

Is it possible to add annotations which indicate that additional information so that the XSD will include it?

A: 

You can use the @XmlElement(required = true) annotation to make an item required. Similar annotations exist for repetition, etc.

See here for annotation classes, the Javadoc has details.

xcut