users@jaxb.java.net

Re: Best practices with JAXB and XML schema

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Tue, 14 Dec 2010 10:52:36 +0100

Hi,

> In JAXB 1.0, the best practice or commonly adopted development process is to
> design the XSD first and generate the java classes. Now that JAXB 2.1 is out
> there and annotations make life a whole lot easier, does it make sense to
> approach the domain model from java classes and generate XSD's from the
> class hierarchy?
>
> I am taking the java classes first approach in my current project. Just
> wondering if this is a commonly adopted development model.

There's both xjc to compile schemas into Java classes and schemagen to
create schemas from annotations.

Which approach to take is normally not the "best practice" question,
this decision is project-driven. If your project is schema-driven
(i.e. you have some schemas you have to comply to), it's
schema-to-Java. If your project is more Java-centric, then schema
generaton is also fine.

Bye,
/lexi