views:

148

answers:

1

I annotated a XmlAdapter class like so:

@XmlTransient
public class DateTimeXmlAdapter extends XmlAdapter<String, DateTime> {

but schemagen.exe generates

<xs:complexType name="xmlAdapter" abstract="true">
    <xs:sequence/>
  </xs:complexType>

so does't skip the class, which was what I expected. XmlAdapter indeed is an abstract class that my transient class inherits from. What should i do?

The reason I refer in a field to DateTimeXmlAdapter is:

@XmlElement(name="StartDatetime")
@XmlJavaTypeAdapter(DateTimeXmlAdapter.class)
protected DateTime startDatetime;

which is correct I think.

A: 

It looks like you've told schemagen to generate schema types for everything in your java package, including the XmlAdapter subclass. It therefore sees your adaptor class, which is marked as @XmlTransient, and therefore doesn't generate a schema type for it. However, it does generate a schema type for XmlAdapter itself.

You need to change how you invoke schemagen so that your adapter class is excluded from the code generation. The @XmlTransient isn't appropriate here, so remove that from the adapter class.

skaffman
see my edit how come I use the adapter in a field
Gerard