我希望我的 Eclipselink 2.3 Marshaller 在编组时执行验证。我已确保Schema
由 a 正确创建SchemaFactory
,我将其传递给Marshaller.setSchema
并且我已通过Marshaller.setEventHandler()
.
元帅结果显然是无效的。到它的模式(在 Eclipse 中验证),但我可以看到我的断点handleEvent(ValidationEvent event)
从未被命中。
我正在编组 XML 片段marshal(Object, XMLStreamWriter)
,并希望编组器根据我通过的模式对这些片段执行验证。
有人知道为什么这没有发生吗?
编辑:
应该发生的验证错误:元素上缺少 2 个属性。
该元素对应于 List<> 中包含的 Java-Object。我正在使用以下方法编组列表:
<xml-element java-attribute="listInstance" xml-path="ListWrapperElement/ListElement" type="foo.ElementType" container-type="java.util.ArrayList"/>
元素本身的映射:
<java-type name="foo.ElementType" xml-accessor-type="PROPERTY">
<java-attributes>
// just <xml-attribute> elements here
</java-attributes>
</java-type>
因此,所有属性都编组到 ListWrapperElement/ListElement/@attribute。其中 2 个缺失且未被验证检测到。