users@jaxb.java.net

Re: minOccurs=maxOccurs=0 produces empty interface -- bug or feature?

From: jon gold <dev_at_samizdatdigital.org>
Date: Fri, 01 Apr 2005 10:17:32 -0800

two things:

1. even if that was (see #2) an okay compiler optimization, it shouldn't
apply in this case -- even though "y" can never occur, "x" is declared
to be mandatory and to occur one time, so there should at least be getX
and setX in the generated interface

2. i'd say that it's not a correct compiler optimization, regardless,
since a FooType may itself (granted, it's not in my simple example
below) be an extension of some other type, and it may be redefining the
"Y" element to not exist, but want to leave it open for further subtypes
to redefine it back in to existence. if the generated interface for
FooType's supertype has getY/setY and then FooType doesn't, then a
subtype of FooType can't redefine the cardinality of "y" without
breaking the java interface inheritance chain.

jon

Perry, Steve wrote:
> Maybe, if something can never occur, what's the point in generating code
> for it?
>
>
>>-----Original Message-----
>>From: jon gold [mailto:dev_at_samizdatdigital.org]
>>Sent: Thursday, March 31, 2005 7:54 PM
>>To: users_at_jaxb.dev.java.net
>>Subject: minOccurs=maxOccurs=0 produces empty interface -- bug or
>
> feature?
>
>>i recently made a typo in a schema and accidentally set both minOccurs
>>and maxOccurs equal to 0 for an element in a sequence of a
>
> complexType,
>
>>let's say:
>>
>><complexType name="FooType">
>> <sequence>
>> <element name="x" type="string"/>
>> <element name="y" type="string"
>> minOccurs="0" maxOccurs="0"/>
>> </...
>></...
>>
>>and got an empty interface for FooType -- ie, no methods getX or setX,
>>even though they were defined to exist. is this a feature of schemas
>
> or
>
>>of xjc, or is it a bug?
>>
>>
>>jon
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>>For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>