users@jaxb.java.net

Re: [ERROR] Two declarations cause a collision in the ObjectFactory class, unsolved by bindings

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Wed, 16 Sep 2009 19:49:15 +0200

Your schema isn't very well suited for code generation, and extremely not so
for Java. Among other strange things, classes com.lqn.Object (with inner
classes Integer, Long,...) and com.lqn.Class will be generated.

In most cases, it is sufficient to customize the element name with a
property name and let xjc derive the class name, e.g.,
 <!-- Line 2050 -->
    <jxb:bindings
node="xs:group[@name='returnTypes']/xs:choice/xs:element[@name='String']">
                  <!-- Customize Element interface name -->
<!-- <jxb:class name="ReturnTypeString"/> -->
                  <jxb:property name="returnTypeString"/>
        </jxb:bindings>

Also, don't use property names beginning with an uppercase letter - these
will be converted to lowercase anyway,

Second, it would be logical to customize the element node with a property,
and the contained complexType with a class.

Third, I recommend to not use <xjc:simple />, as this may result in
additional secondary conflicts, at least until all other problems have been
resolved.

Still, after all this, you'll wind up with lots of two or three levels of
inner class names resulting from the anonymous complex types. Using these in
a program is going to cause a headache of the most ferocious kind.

Most regrettfully yours ;-)
-W

On Wed, Sep 16, 2009 at 3:00 PM, Loïc Quéran <loic.queran_at_gmail.com> wrote:

> Hi,
>
> jaxb-ri-20090206 ...
>
> Hereafter attached is an XSD from which I can't generate java classes. I
> have customized bindings to avoid naming conflicts, but there are still
> collisions in the ObjectFactory. The strange thing about this is that
> apparently similar bindings (binding.xjb line 99 and line 87) produce
> different results: the former fixes the ObjectFactory conflict, while the
> latter does not. I've tried to debug this. The problem comes from the
> instantiation of CElementInfo, but I can't find out why it is performed in
> some cases (is it linked to yet unresolved references ?), but not in all
> cases.
>
> I attach:
> 1 ) The binding,
> 2 ) The XSD
> 3 ) The error log
>
> Thanks in advance for any help.
>
> Loïc
>
> C:\jaxb-ri-20090206\samples\rapid>xjc -b binding.xjb work.xsd
> parsing a schema...
> compiling a schema...
> [ERROR] Two declarations cause a collision in the ObjectFactory class.
> line 1241 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] (Related to above error) This is the other declaration.
> line 1392 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] Two declarations cause a collision in the ObjectFactory class.
> line 1428 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] (Related to above error) This is the other declaration.
> line 1253 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] Two declarations cause a collision in the ObjectFactory class.
> line 2203 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] (Related to above error) This is the other declaration.
> line 2167 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] Two declarations cause a collision in the ObjectFactory class.
> line 2049 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] (Related to above error) This is the other declaration.
> line 2124 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] Two declarations cause a collision in the ObjectFactory class.
> line 1550 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] (Related to above error) This is the other declaration.
> line 1592 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] Two declarations cause a collision in the ObjectFactory class.
> line 1629 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] (Related to above error) This is the other declaration.
> line 1665 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] Two declarations cause a collision in the ObjectFactory class.
> line 1942 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] (Related to above error) This is the other declaration.
> line 2020 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] Two declarations cause a collision in the ObjectFactory class.
> line 2037 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> [ERROR] (Related to above error) This is the other declaration.
> line 2041 of file:/C:/jaxb-ri-20090206/samples/rapid/work.xsd
>
> Failed to produce code.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>