JAXB-ElipseLink: @XmlJavaTypeAdapter and the type-attribute

爷,独闯天下 提交于 2019-12-24 07:28:29

问题


I am using @XmlJavaTypeAdapter to marshal fields of type Map to XML. This results in EclipseLink-MOXy creating an xsi:type="<myValueType>"-attribute on the output xml-element. Upon validation the referenced type can of course not be found.

Is there any way of suppressing the generation of this attribute?

PS: An XmlAdapter-tag would be handy :)


回答1:


Turns out the type-attribute had nothing to do with the @XmlJavaTypeAdapter annotation. It was caused by the fact, that the Map's elements were of a derived type and MOXy correctly marshalled their type to a type-attribute.

Using <xml-element-ref> instead of <xml-element> solved the issue.



来源:https://stackoverflow.com/questions/8912925/jaxb-elipselink-xmljavatypeadapter-and-the-type-attribute

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