users@jaxb.java.net

Re: strange error message when using XJC (via the Maven 2 plugin) to generate POJOs for XMPP

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Mon, 23 Oct 2006 14:38:35 +0200

James Strachan wrote:
> As an experiment I started a little maven project to try use JAXB's
> XJC to auto-create the POJOs for working with the XMPP protocol...
>
> https://svn.apache.org/repos/asf/incubator/activemq/sandbox/activemq-xmpp/
>
> I had to tweak the schemas a little as quite a few of the schemas at
> http://xmpp.org/schemas/ seem invalid.
>
> I've got most of the errors licked now I think, but I get the
> following errors which I can't make head nor tail of.
>
> I just wondered if anyone else could figure out what the problem is?
> The XSDs all seem valid from IDEA at least :) Whats particularly
> confusing is I can't find 'MessageOrPresenceOrIq' in any of the XSDs.

The problem is with your "stream" type from streams.xsd. It contains the
following definition:

<xs:choice minOccurs="0" maxOccurs="1">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="client:message"/>
        <xs:element ref="client:presence"/>
        <xs:element ref="client:iq"/>
</xs:choice>
<xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="server:message"/>
        <xs:element ref="server:presence"/>
        <xs:element ref="server:iq"/>
        <xs:element ref="db:result"/>
        <xs:element ref="db:verify"/>
</xs:choice>

These choices are mapped onto two choice properties. Names of these properties
are constructred from the names of the element. Only three first elements are
considered, no namespace prefixes taken into an account. Therefore you have
MessageOrPresenceOrIq for both choices.
To resolve it, give one of the choices another name with jaxb:property
customization.

Another problem with this type is with two xs:any properties. I am not sure if
it is allowed at all with JAXB2, but you could try renaming one of these
properties (again, with jaxb:property annotations).

Bye.
/lexi