• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Castor minOccurs bean generation

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Blikkies Marais
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, it was my mistake, it is generating correctly, I just missed it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic