users@jaxb.java.net

Re: code generated from a list of 'token' type

From: Kohsuke Kawaguchi <kohsuke.kawaguchi_at_sun.com>
Date: Thu, 06 Oct 2005 11:01:59 -0700

jonathan gold wrote:
> i've noticed that if i have
>
> <sequence>
> <element name="foo" type="string" maxOccurs="unbounded"/>
> </sequence>
>
> i get a corresponding accessor to a List< String >, but if the type is
> 'token', then i get an accessor to a List< JAXBElement< String > >. i
> presume this is because token is more sophisticated than 'string' and
> can't be directly passed through to the xml (it has to be trimmed first,
> cleaned up, etc).
>
> not a big deal, but wanted to see if i'm overlooking some easy way to
> marshal/unmarshal tokens but allow java users to get/set Strings. i
> could always use a custom DatatypeConverter and force xjc to bind the
> 'foo' element to String, right?

This is because xs:token requires a whitespace normalization, and the
only way to do that is by using an adapter. Previously when you got an
adapter on a list property, it worked against the whole list, not
individual items in the list, so that's why XJC needed to put
List<JAXBElement<String>>.

Given that this adapter clunkiness is fixed now, I think this code
generation behavior can be fixed now.

Thanks for pointing this out.


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com