users@jaxb.java.net

Identifying Choice vs minOccurrs=0

From: Sachith Dhanushka <sachith.dhanushka_at_gmail.com>
Date: Sat, 23 Jun 2007 00:46:40 -0400

Hi,

I am trying to look at a set of JAXB2 generated classes using JAXB2
reflection library and generate a schema
model. The schema model is specific to the project I am working now.

1. In doing so, I have a problem in identifying Choice vs MinOccurrs=0. Say
for exmapl I see a class which has two properties, both having
required=false (or required attribute is not annotated). How can I know
whether I should put these two attributes under a Choice element in the
schema or put under Sequence and set MinOccurrs=0?

Can I assume both are semantically correct?

2. Again I start with a schema which has a simple type defined to define a
restriction. How can I deduce this by looking at the generated JAXB2 code?
Take for example following schema fragment.

<xs:element name="bookCategory">
  <xs:simpleType>
     <xs:restriction base="xs:NCName">
     <xs:enumeration value="magazine" />
     <xs:enumeration value="novel" />
     <xs:enumeration value="fiction" />
     <xs:enumeration value="other" />
     </xs:restriction>
  </xs:simpleType>
</xs:element>

Having generated code for this I can only see following.

@XmlElement(required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
protected String bookCategory;

How can I deduce the restriction by looking at this java code?


Thanks,
SD