users@glassfish.java.net

choice element annotation?

From: <glassfish_at_javadesktop.org>
Date: Thu, 19 Feb 2009 11:10:25 PST

is there anyway to annotate my webservice pojo to indicate that there is a choice between two attributes of a class, such that when i deploy the webservice to glassfish the generated xsd will enforce the choice?

for example, if my class is:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "purchase", propOrder = {
    "id",
    "name"
})
public class User {
    protected String name;
    protected String user;
     ....
}



how would i annotate my class so that glassfish generates an xsd like:

<xs:complexType name="user">
    <xs:sequence>
          <xs:choice minOccurs="1" maxOccurs="1">
               <xs:element name="id" type="xs:string" ></xs:element>
                <xs:element name="name" type="xs:string" ></xs:element>
            </xs:choice>
     </xs:sequence>
</xs:complexType>
[Message sent by forum member 'ab11' (ab11)]

http://forums.java.net/jive/thread.jspa?messageID=332980