users@jaxb.java.net

Re: Can RI handle validation?

From: Kohsuke Kawaguchi <kohsuke.kawaguchi_at_sun.com>
Date: Fri, 27 Jan 2006 12:35:48 -0800

Compile that schema by using JAXP SchemaFactory, and then set that to
marshaller. Then you get all validation errors as it runs.

Sakala, Adinarayana wrote:
> I am using RI EA3 and I was wondering if validation is handled by RI.
>
> Here is a scenario,
>
> Schema:
> <complexType name="OccuringStruct">
> <sequence minOccurs="1" maxOccurs="5">
> <element name="varFloat" type="xsd:float"/>
> <element name="varInt" type="xsd:int" minOccurs="0"/>
> <element name="varString" type="xsd:string"/>
> </sequence>
> </complexType>
>
> The above gets mapped to a List property.
> Here is my client code.
>
> OccuringStruct x = new OccuringStruct();
> List<Serializable> theList = x.getVarFloatAndVarIntAndVarString();
> //NOTE I am populating the List in Wrong order!!!
> theList.add(new Integer(1));
> theList.add(1111.14f);
> theList.add("x2");
>
> If you observe, i populated the sequence in wrong order. I would have expected a marshalling error instead the list is converted to xml using the order i used.
>
> I see that this will be very common error that non schema savvy users will do if they are provided with a list.
>
> Can somebody shed some light on if this is a known issue? or if there is a way to turn on validation so that users know right away what the problem is.


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com