JAXB-ElipseLink:@XmlJavaTypeAdapter和type-attribute [英] JAXB-ElipseLink: @XmlJavaTypeAdapter and the type-attribute
问题描述
我使用@XmlJavaTypeAdapter来编组Map to XML类型的字段。这导致EclipseLink-MOXy在输出xml-element上创建 xsi:type =< myValueType>
-attribute。
验证时,当然无法找到引用的类型。
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:XmlAdapter-tag会很方便:)
PS: An XmlAdapter-tag would be handy :)
推荐答案
结果显示type-attribute与@XmlJavaTypeAdapter注释无关。
这是因为Map的元素是派生类型,MOXy正确地将它们的类型编组为类型属性。
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.
使用< xml-element-ref>
而不是< xml-element>
解决了这个问题。
Using <xml-element-ref>
instead of <xml-element>
solved the issue.
这篇关于JAXB-ElipseLink:@XmlJavaTypeAdapter和type-attribute的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!