You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Diego Nieto Cid <dn...@gmail.com> on 2017/01/12 22:29:59 UTC

Override a previous JAXB binding [cxf-codegen-plugin]

Hello

I want to remove some manual modifications I've made to an xjc generated
namespace through the use of an external binding file and the
cxf-codegen-plugin to process a WSDL with embedded schema. [1]

My jaxws bindings file include the following two JAXB bindings

    <jaxb:bindings
        node="//xs:element[@minOccurs=0]/xs:simpleType">
      <xjc:javaType name="java.lang.Double"
          adapter="my.adapters.TwoDecimalsDoubleAdapter" />
    </jaxb:bindings>

    <jaxb:bindings
        node="//xs:element[@name='precio_unitario']/xs:simpleType">
      <xjc:javaType name="java.lang.Double"
          adapter="my.adapters.FourDecimalsDoubleAdapter" />
    </jaxb:bindings>

Double values need to be rounded when marshalling so I created an adapter
for two and four decimal places. The idea of that pair of bindings is that
the first one will apply the two decimal places rounding to all optional[2]
doubles[3] and the second will apply the four decimal places rounding to a
field which is allowed a bit higher precision.

However, when I run the generate-sources goal Maven prints the following
message:

    compiler was unable to honor this conversion customization. It is
attached to a wrong place,
    or its inconsistent with other bindings

Is there a way to override previous bindings? Or some way to solve this
problem other than what is outlined in [2]?

Thanks


[1] The overall context is explained in this stack overflow question:
http://stackoverflow.com/questions/41621879

[2] For required fields I want to use a primitive 'double' in other
binding. So, I can't have a global binding
for the two decimals rounding.

Hm, I may be able to use the global binding for the optional values, and
overrides for the required fields and this
high precision field which is optional too. That way collisions would be
prevented...for the time being.

[3] I'm still looking for a way to make sure the simpleType is actually a
restriction of the xsd:double type