users@jaxb.java.net

Help with JAXB API

From: Marc Dumontier <dumontier_at_mshri.on.ca>
Date: Fri, 17 Jan 2003 16:02:47 -0500

Hi all,

This question is directed mostly to developers of JAXB.

I'm trying to write code which will generated classes associated with
JAXB autogenerated classes which represent choice types (<xs:choice>).
Here's my idea basically

JAX has generated code from the following schema type:

<xs:complexType name="BIND-action-object1">
<xs:choice>
<xs:element ref="BIND-action-object_none" />
<xs:element name="BIND-action-object_object"
type="BIND-action-object_object1" />
<xs:element name="BIND-action-object_location"
type="BIND-action-object_location1" />
</xs:choice>
</xs:complexType>


I want to generate class that looks something like the following

class BINDActionObject1_Choice {

     public static int BIND-action-object_object = 0;
     public static int BIND-action-object_location = 1;

     private int choice;

    /* this function should set the choice variable based on which
object is not null*/
    boolean bind(BINDActionObject1 obj);

    int getChoice();

     /*set the right object based on choice, and update choice variable*/
    boolean setChoice(int choice, Object obj);

     /*checks choice, get retrieves the right object */
    Object getObject();

}


The question I have is, is there a function available to me to get the
right names for the getXXX() functions which are generated.

what i basically did this afternoon was write the code to parse the
schema, find the choices, make a structure which includes the name of
the complexType and the name of the sub-elements. The next step is to
generate the code, but I think i should probably be using the jaxb api
to accomplish this task instead, so i know i have the right names incase
of any custom binding, etc.

Anyone have any tips?


thanks in advance.
Marc Dumontier