XJC javaType adapter in complexType

我们两清 提交于 2019-12-08 03:52:51

问题


I want to get XJC to use the javaType tag in a complexType when generation beans. Is this not allowed? I'm really missing good documentation and some understandable error message.

Here is what I am trying which fails with the errors:

  • compiler was unable to honor this conversion customization. It is attached to a wrong place, or its inconsistent with other bindings.
  • (the above customization is attached to the following location in the schema)

Here is the XSD:

<xs:complexType name="MyMap">
  <xs:annotation>
    <xs:appinfo>
      <xjc:javaType name="my.company.HashMapHidingGenerics" adapter="my.company.adapter.MyMapAdapter" />
    </xs:appinfo>
  </xs:annotation>
  <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="entry" type="MyEntry"/>
  </xs:sequence>
</xs:complexType>
<xs:complexType name="MyEntry">
  <xs:attribute name="someAttribute" use="optional"/>
</xs:complexType>

回答1:


Bad news: <javaType> only supports simple types (see Binding Declarations and Is it possible to use JAXB to map from schema to a java.util.Map?).

However you can achieve what you need by using @XmlAdapter.



来源:https://stackoverflow.com/questions/9844502/xjc-javatype-adapter-in-complextype

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