users@jaxb.java.net

Re: XJC not generating XmlElement annotations w/o a logical pattern

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Fri, 20 Aug 2010 21:30:17 +0200

These annotations are for types that aren't represented as Java
classes where the annotation/documentation
would result in some javadoc. Hence, they are lost.
-W

On 20 August 2010 21:00, Young Matthew (4004)
<matthew.young_at_forsakringskassan.se> wrote:
> Using latest XJC/JAXB with java 1.5....
>
> Sometimes the XJC tool doesn't generate XmlElement annotations for certain
> properties without a logical pattern/reason.  Below is a snippet of the XML
> Schema and the resulting class file.  Running XJC from the command line.
>
> Anybody else getting this?  Not the only class that is missing annotations
> (several) so it isn't tied to the type.
>
>
> [XML schema]
>
> ....
>
> <xs:simpleType name="createId">
>     <xs:annotation>
>          <xs:documentation>Creation ID</xs:documentation>
>     </xs:annotation>
>      <xs:restriction base="xs:string" />
> </xs:simpleType>
> <xs:simpleType name="createTimeStamp">
>     <xs:annotation>
>         <xs:documentation>Time stamp when the object was
> created</xs:documentation>
>     </xs:annotation>
>     <xs:restriction base="xs:dateTime" />
> </xs:simpleType>
> ......
>
> <xs:complexType name="Base" abstract="true">
>     <xs:sequence>
>         <xs:element name="id" type="pojo:id" maxOccurs="1" minOccurs="1" />
>         <xs:element name="name" type="pojo:name" maxOccurs="1" minOccurs="1"
> />
>         <xs:element name="fromTimeStamp" type="pojo:fromTimeStamp"
> maxOccurs="1" minOccurs="1" />
>         <xs:element name="toTimeStamp" type="pojo:toTimeStamp" maxOccurs="1"
> minOccurs="0" />
>         <xs:element name="createId" type="pojo:createId" maxOccurs="1"
> minOccurs="0" />
>         <xs:element name="createTimeStamp" type="pojo:createTimeStamp"
> maxOccurs="1" minOccurs="1" />
>         <xs:element name="updateTimeStamp" type="pojo:updateTimeStamp"
> maxOccurs="1" minOccurs="1" />
>     </xs:sequence>
> </xs:complexType>
>
>
> [Java class]
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "Base", propOrder = {
>     "id",
>     "name",
>     "fromTimeStamp",
>     "toTimeStamp",
>     "createId",
>     "createTimeStamp",
>     "updateTimeStamp"
> })
> @XmlSeeAlso({
>     RelationType.class,
>     Relation.class,
>     ElementType.class,
>     Element.class
> })
> public abstract class Base {
>
>     @XmlElement(required = true, type = String.class)
>     @XmlJavaTypeAdapter(Adapter4 .class)
>     protected Long id;
>     @XmlElement(required = true)
>     protected String name;
>     @XmlElement(required = true, type = String.class)
>     @XmlJavaTypeAdapter(Adapter3 .class)
>     protected Date fromTimeStamp;
>     @XmlElement(type = String.class)
>     @XmlJavaTypeAdapter(Adapter3 .class)
>     protected Date toTimeStamp;
>     protected String createId;
>     @XmlElement(required = true, type = String.class)
>     @XmlJavaTypeAdapter(Adapter3 .class)
>     protected Date createTimeStamp;
>     @XmlElement(required = true, type = String.class)
>     @XmlJavaTypeAdapter(Adapter3 .class)
>     protected Date updateTimeStamp;
>
> .....