I am using Castor to generate
java beans from a xml schema. However, it is not generating the expected results.
I have a schema (Letters.xsd) and am using Castor version 1.0.3, but have also tried the latest version of Castor (version 1.1.2.1) with the same results.
I am looking at changing the Letters.xsd to make the 'Signatory' mandatory, so I set the 'minOccurs' to 1.
<xs:complexType name="MaturityLetter">
<xs:sequence>
<xs:element ref="ControlData" />
<xs:element ref="MaturityCase" minOccurs="0" />
<xs:element ref="UnitLifeContract" maxOccurs="10" />
<xs:element ref="Recipient" />
<xs:element ref="LifeAssured" />
<xs:element ref="Lender" minOccurs="0" />
<xs:element ref="Claimant" />
<xs:element ref="Grantee" minOccurs="0" maxOccurs="3" />
<xs:element ref="Signatory"
minOccurs="1" maxOccurs="10" />
<xs:element ref="MoneyLaundering" minOccurs="0" maxOccurs="6" />
<xs:element ref="Requirement" minOccurs="0" maxOccurs="60" />
<xs:element ref="Payment" minOccurs="0" maxOccurs="10" />
<xs:element ref="FundQuote" minOccurs="0" maxOccurs="100"/>
<xs:element ref="Pack" />
<xs:element ref="Fmisa" minOccurs="0" maxOccurs="10"/>
</xs:sequence>
<!-- type of document -->
<xs:attributeGroup ref="attrDocumentStyle"/>
</xs:complexType>
However, when I generate the java beans, this check is not there. There is a check for the existing 'maxOccurs="10"' though.
E.g.
if (!(index < 10)) {
throw new IndexOutOfBoundsException("setSignatory has a maximum of 10");
There is no check whether there is at least one Signatory. I have tried removing minOccurs, because the default is supposed to be minOccurs="1" anyway, but still the same result.
Any Ideas? Thanks
[ December 05, 2007: Message edited by: Blikkies Marais ]