users@jaxb.java.net

Re: schemagen and xsd documentation annotations

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 05 Jun 2007 16:08:29 -0700

Naz Quadri wrote:
> Hi,
>
> I have a set of Java classes which are being used to create an xml
> schema using schemagen, or more specifically
> JAXBContext.generateSchema(). I would like to be able to add comments to
> my classes as annotations if possible and have these injected into the
> generated schema as documentation annotations. I'm pretty certain there
> is no Java annotation to do this but see below for how it might look
> with an invented annotation.

Yes, things like this is certainly conceivable.

When schemagen acts on the source code it's even possible to just take
the javadoc comment.

> If this is not possible is there any other way ? Would it be possible to
> write the class and field comments into an xml file and hook into the
> schemagen process and inject the comments into the schema by using a
> plugin of some kind ?

Unfortunately right now schema generator class is not extensible. It
doesn't have the in-memory mutable tree representation of the schema to
be written (unlike XJC), and without it, one cannot really write
"plugins" that tweak it before it's written down as schema document.

I'm also OK with just adding this capability to the JAXB RI itself
without introducing a formal plugin mechanism. Propagating docs seem
like a reasonable enough change.

If anyone could help us hack the code, that would be great. Otherwise
please file this in the issue tracker for future tracking purpose.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com