Hi Mirza, You are right there is a bug; we have listed it in bugzilla:
http://bugzilla.exolab.org/show_bug.cgi?id=1049 http://bugzilla.exolab.org/show_bug.cgi?id=960 Right after the integration of the binding file, I will move that issue up in my priority list. Sorry for the inconvenience, Arnaud > -----Original Message----- > From: Baig, Mirza [mailto:mirza.baig@;experian.com] > Sent: Thursday, November 07, 2002 11:36 PM > To: [EMAIL PROTECTED] > Subject: [castor-dev] Is Validation of complexTypes with > xs:restrictions supported?? > > Hello, > > It looks like there's a bug in Castor validation of complex types > that > restrict other complex types. From looking at the code, it looks as > if the > the class associated with a complexType automatically inherits all > of the > field descriptors from the complexType that it is restricting. > Instead the > class for the complextype should only contain field descriptors > detailed in > its own <xs:restriction> bloack and not those of the base > complexType. > XMLSpy seems to validate this type of document correctly, meaning > that it > complains if the restricted complexType has any elements that are > not > declared in its own <xs:restriction> block. Castor on the other > hand, will > accept such a document as valid. Is this a bug or am I doing > something > wrong? > > Here's a sample schema and xml doc to illustrate the behaviour I'm > seeing: > > Schema: > > <?xml version="1.0" encoding="UTF-8"?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > elementFormDefault="qualified" attributeFormDefault="unqualified"> > > <!-- The super set of addons that contains 3 elements A,B,C -- > > > > <xs:complexType name="Super_AddOns"> > <xs:sequence> > <xs:element name="A" type="xs:string"/> > <xs:element name="B" type="xs:string"/> > <xs:element name="C" type="xs:string"/> > </xs:sequence> > </xs:complexType> > > <!-- The subset of addons that contains only 2 elements A, B - > -> > > <xs:complexType name="Sub_AddOns"> > <xs:complexContent> > <xs:restriction base="Super_AddOns"> > <xs:sequence> > <xs:element name="A" > type="xs:string"/> > <xs:element name="B" > type="xs:string"/> > </xs:sequence> > </xs:restriction> > </xs:complexContent> > </xs:complexType> > > > > <!-- product one declares that it has an element of the > subtype > Sub_AddOns --> > > <xs:element name="product_1"> > <xs:complexType> > <xs:sequence> > <xs:element name="AddOns" > type="Sub_AddOns"/> > </xs:sequence> > </xs:complexType> > </xs:element> > > </xs:schema> > > With this schema, the following document shouldn't validate, but > with the > Castor classes, it unmarshals and validates without throwing an > exception: > > <!-- product_1 is set to have addOns of type Sub_AddOns which only > allows > elements A and B, thus the C element should cause this document to > be > invalid --> > > <product_1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:noNamespaceSchemaLocation="C:\xml\castor-0.9.4.1\Untitled1.xsd"> > <AddOns> > <A>safljaslfas</A> > <B>asdlfjasf</B> > <C>safasdf</C> > </AddOns> > </product_1> > > > Any ideas? > > Thanks in advance for your help, > > -mirza > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
