Class reuse with JAXB bindings don't honour SimpleTypes

梦想与她 提交于 2019-12-07 14:50:15

问题


I'm trying to reuse classes that are already compiled and available. This looks to be achievable by declaring bindings to the pre-existing classes as per example bindings extract below:-

<jaxb:bindings schemaLocation="MyExample.xsd">
    <jaxb:bindings node="//xs:simpleType[@name='MySimpleType']">
        <jaxb:class ref="com.example.MySimpleType" />
    </jaxb:bindings>
    <jaxb:bindings node="//xs:complexType[@name='MyComplexType']">
        <jaxb:class ref="com.example.MyComplexType" />
    </jaxb:bindings>
</jaxb:bindings>

The problem is that whilst complex types work just fine, the simple types are ignored and still generated....

I've tried a variety of different notations (e.g. scd) with no success on the Simple Types.

Any ideas or help very welcome....


回答1:


If the generated class you are trying to reference is an enumeration (i.e. it implements javax.xml.bind.annotation.XmlEnum), then you need to use:

jaxb:typesafeEnumClass

instead of

jaxb:class

in the bindings.



来源:https://stackoverflow.com/questions/15656803/class-reuse-with-jaxb-bindings-dont-honour-simpletypes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!