users@jaxb.java.net

JAXB/XJC generated annotations and xs:documentation

From: Lucas Madar <lucas_at_mcsnw.com>
Date: Fri, 08 May 2009 14:05:06 -0700

Hi,

I have a schema that I'm successfully compiling and using with XJC. I'm
wondering if I can utilize the schema xs:documentation tags as
annotations in the generated Java code. For instance, I'd like to see
something like the following java code from the following schema snippet.

I've attempted to write an xjc plugin that iterates through classes and
finds documentation via
ClassOutline.target.getSchemaComponent().getAnnotation().getAnnotation().getDocumentation(),
but I can't get the lang attribute that way and I can't seem to figure
out how to do the same thing for fields. I've also looked at the
annotate commons project, but it only deals with custom appinfo.

Additionally, is there a better way to do this? Am I missing something
painfully obvious? :)

Thanks,
Lucas Madar

code:
@XmlDocumentation(lang="EN", value="information about project")
public class Project {
    @XmlDocumentation(lang="EN", value="information about reference")
    protected String reference;

schema fragment:
<xs:element name="reference" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="EN">information about
reference</xs:documentation>
</xs:annotation>
</xs:element>

<xs:element name="project">
<xs:annotation>
<xs:documentation xml:lang="EN">information about project</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="hierarchyEntity">
<xs:sequence> ...
<xs:element ref="reference" minOccurs="0" maxOccurs="unbounded"/>