users@jaxb.java.net

Validation question

From: Petra Malik <petra_at_cs.waikato.ac.nz>
Date: Thu, 18 Dec 2003 11:36:36 +1300

I noticed the following "problem" and wondered whether this is a bug or
a feature :-)

If I have an element "Element" defined as a sequence of 0 to infinity
Foo elements
followed by 0 to infinity Bar elements, the generated Jaxb class looks
like this:
interface Element {
  List getFoo();
  List getBar();
}

Then assume we've got
Element element = factory.createElement();
Foo foo = factory.createFoo();
Bar bar = factory.createBar();

Since lists are not type safe in Java,
I can add foo as well as bar into the list of Foo:

element.getFoo().add(foo);
element.getFoo().add(bar);

If I validate element, should it be valid or not?
I expected to get a validation exception, since
I added a bar element into the foo list, and was surprised
to learn that Jaxb thinks this is valid and can even
marshal it.

Is it a bug or a feature?

Regards,
Petra



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net