views:

835

answers:

2

Do people have any recommendations on how i could write my own custom JAXB annotation handling class to support the generation of xs:annotation/xs:documentation elements in the xsd schema?. I'd like to create a new java annotation "@XmlAnnotation" which would include a "documentation" attribute. I'd then make these classes available to the JAXB schema generator via the classpath. The schema generator would then take this sample java code

@XmlRootElement(name="ClientData")
public class ClientData {

/**
 * The first address field of the person
 */
@XmlAnnotation(documentation="The first address field of the client")
private String address1 = null;
}

and create this xsd schema

<xs:complexType name="clientData">
  <xs:sequence>
<xs:element minOccurs="0" name="address1" type="xs:string">
    <xs:annotation>
  <xs:documentation>The first address field of the client</xs:documentation>
</xs:annotation>

Would it be easier to extend from the existing @XmlElement annotation class, and just add support of an extra documentation attribute?

+1  A: 

This XmlRootElement is almost empty ( http://docjar.org/src/api/javax/xml/bind/annotation/XmlRootElement.java, there is not 'active' code inside

The main modification would be to change the code using this annotation and generating the xsd file.

Pierre
A: 

That would only allow the construct for the root element. It is valid in just about ALL the xs namespace elements.

I don't understand why it wasn't supported as standard.