users@jaxb.java.net

specifying minOccurs when using _at_XmlElementRef?

From: James.Strachan <james.strachan_at_gmail.com>
Date: Tue, 24 Jul 2007 09:46:33 -0700 (PDT)

So I really like @XmlElementRef; it means if a base class is used throughout
a POJO model (such as a Task in the example given in the JavaDoc)

https://jaxb.dev.java.net/nonav/jaxb20-pfd/api/javax/xml/bind/annotation/XmlElementRef.html

then you don't have to litter your code on all field/properties of type Task
with an @XmlElements({every single @XmlElement goes here}).

By default the use of @XmlElementRef in code like this...
  @XmlElementRef
  List<Task> tasks;

generates a choice as follows...
  <xs:choice maxOccurs="unbounded">
    <xs:element ref="jar">
    <xs:element ref="javac">
     ...

I don't see a way to specify the minOccurs property. I'd like it to be zero
by default :). Anyone any clue how you could specify 0 or 1?

If there's no way to do this via the JAXB 2 standard annotations; I wonder
if we could add an extension annotation in the com.sun.* namespace that the
schemagen could use?
-- 
View this message in context: http://www.nabble.com/specifying-minOccurs-when-using-%40XmlElementRef--tf4137223.html#a11767246
Sent from the java.net - jaxb users mailing list archive at Nabble.com.