Question

I would like my Eclipselink 2.3 Marshaller to perform validation upon marshalling. I have made sure that the Schema is correctly created by a SchemaFactory, i am passing it to Marshaller.setSchema and i have registered a handler via Marshaller.setEventHandler().

The marshal result is clearly not valid acc. to its Schema (verified in Eclipse), nevertheless i can see that my breakpoint in handleEvent(ValidationEvent event) is never hit.

I am marshalling XML-Fragments using marshal(Object, XMLStreamWriter) and would expect the Marshaller to perform validation on these fragments according to the Schema i passed.

Anybody any idea why this is not happening?

EDIT:

The Validation error that should occur: 2 missing attributes on an element.

The element corresponds to a Java-Object that is contained in a List<>. I am marshalling the List using:

<xml-element java-attribute="listInstance" xml-path="ListWrapperElement/ListElement" type="foo.ElementType" container-type="java.util.ArrayList"/>

The mapping for the element itself:

<java-type name="foo.ElementType" xml-accessor-type="PROPERTY">
    <java-attributes>
        // just <xml-attribute> elements here
    </java-attributes>
</java-type>

Therefore all attributes are marshalled to ListWrapperElement/ListElement/@attribute. 2 of these are missing and not detected by validation.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top