> -----Original Message----- > From: Glen Mazza [mailto:[email protected]] > Sent: Tuesday, June 01, 2010 7:14 AM > To: [email protected] > Subject: Re: xsd validation no checking. why? > > > Are you using JAXB? It's doesn't validate many types of constraints. > I > believe XMLBeans does a better job, but haven't used it before.
JAXB 2 doesn't do any schema validation by default. If you enable its schema validation, it should do full validation according to the schema. In JAXB 2, it uses the schema validation functionality in JAXP. This link mentions how to do this: < http://stackoverflow.com/questions/805989/can-one-validate-marshalled-xm l-with-jaxb-2-0 >. > jimmy6 wrote: > > > > How come the following restriction not working? Suppose it can only > pass > > in A and C. But why my following code is able to pass through? > > HelloWorld helloWorld = new HelloWorld(); > > helloWorld.setType(HelloWorld.Type.B); > > WebClient client = > WebClient.create("http://127.0.0.1:8080/"); > > Response r = > > > client.path("rest/api/rest/helloWorldService/.xml").accept("text/xml"). > post(helloWorld); > > > > <jaxrs:schemaLocations> > > > > > <jaxrs:schemaLocation>classpath:com.abc.sample.cxf.helloWorld.xsd</jaxr > s:schemaLocation> > > </jaxrs:schemaLocations> > > > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > > xmlns:tns="http://127.0.0.1:8080" elementFormDefault="qualified" > > targetNamespace="http://127.0.0.1:8080"> > > <xs:element type="tns:HelloWorld" name="HelloWorld"/> > > <xs:complexType name="HelloWorld"> > > <xs:annotation> > > <xs:documentation>Hello world object that demonstrates the > > service</xs:documentation> > > </xs:annotation> > > <xs:sequence> > > <xs:element type="xs:string" name="message"> > > <xs:annotation> > > <xs:documentation>the message</xs:documentation> > > </xs:annotation> > > </xs:element> > > <xs:element name="type"> > > <xs:simpleType> > > <xs:restriction base="xs:string"> > > <xs:enumeration value="A"/> > > <xs:enumeration value="C"/> > > </xs:restriction> > > </xs:simpleType> > > </xs:element> > > </xs:sequence> > > <xs:attribute type="xs:dateTime" use="required" name="date"/> > > <xs:attribute type="xs:int" use="required" name="integer"/> > > <xs:attribute type="xs:boolean" use="required" name="enable"/> > > </xs:complexType> > > </xs:schema> > > > > > > -- > View this message in context: http://old.nabble.com/xsd-validation-no- > checking.-why--tp28726073p28742431.html > Sent from the cxf-user mailing list archive at Nabble.com.
