users@jaxb.java.net

_at_XmlJavaTypeAdapter questions

From: Melchior, Joris <Joris.Melchior_at_fmr.com>
Date: Mon, 25 Aug 2008 09:13:26 -0500

Hi Everyone,

I'm working from an existing schema that is not really ideal for
creating our models but I have little control over it so I'm trying to
convert things using binding instructions in an external (xjb) file.

One of things I'm struggling with is that I can't find a way to change
the 'depth' of the model, for example, we get things with this
structure;

<monthyeartype>
        <month>01</month>
        <year>2005</year>
</monthyeartype>

For our purposes we would like to convert this to a java.util.Date or
joda.LocalDate. I've tried using a binding file with javaType
instructions but I can only seem to get that to work for simple elements
and not for complexTypes. When using it on complexTypes the xjc compiler
gives me the following error ;

[xjc] [ERROR] compiler was unable to honor this javaType customization.
It is attached to a wrong place, or its inconsistent with other
bindings.

Are the javaType conversions only meant for simple xml types or can
complex types be converted as well? If so, where can I find some
documentation/samples of this?

Another thing I noticed is that where it does create the proper adapter
for me when using conversion of simple types the generated code is
annotated like this;

@XmlJavaTypeAdapter(Adapter4 .class)

The space between 'Adapter4' and '.class' is generated and gives errors
as you would expect.

I'm working with version 2.1.7.

Any help is appreciated.

Thanks, Joris Melchior.