users@jaxb.java.net

Re: Identifying Choice vs minOccurrs=0

From: Sachith Dhanushka <sachith.dhanushka_at_gmail.com>
Date: Sat, 7 Jul 2007 20:02:11 -0400

Wondering again if there is anyone out there who can help me to understand
and fix the problem :(

Thanks,
SD

On 6/23/07, Sachith Dhanushka <sachith.dhanushka_at_gmail.com> wrote:
>
> 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
>
>
>