users@jaxb.java.net

RE: Binding of element type to custom class

From: Perry, Steve <Steve.Perry_at_fnf.com>
Date: Thu, 31 Mar 2005 17:12:27 -0600

Have you tried using a targetNamespace attribute on your schema element
definition, say, "http://myhealthbank.com"? That should do it (although
I think the top level directory will be called "generated").
 
You can also use a binding customization:
 
    <jxb:bindings schemaLocation="whatever.xsd" node="/xs:schema">
        <jxb:schemaBindings>
            <jxb:package name="com.myhealthbank"/>
        </jxb:schemaBindings>
    </jxb:bindings>
 
This is the format you'd use for an external binding customization. It
appears you are using the customization as a schema annotation, but I'm
sure the syntax is similar.
 
Are there other classes in the schema that contains the fragment in your
example? If so, the customization I've shown above will generate them
all to the same package.
 
Last, you can specify the package on the command line (or as a parameter
to the xjc Ant task).
 
HTH,
 
--steve
 
-----Original Message-----
From: Christian Pich [mailto:Christian.Pich_at_qcsi.com]
Sent: Thursday, March 31, 2005 5:01 PM
To: users_at_jaxb.dev.java.net
Subject: Binding of element type to custom class
 
I cannot figure out how I bind an element (of complex type) to my own
class.
I tried the following annotation:
 
    <xs:complexType name="Payer">
        <xs:annotation>
            <xs:appinfo>
                <jaxb:class name="com.myhealthbank.Payer"/>
            </xs:appinfo>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="federalTaxID" type="xs:string"/>
            <xs:element name="code" type="xs:string"/>
            <xs:element ref="Address"/>
        </xs:sequence>
    </xs:complexType>
 
In essence, I'd like to bind the payer type to my class
com.myhealthbank.Payer
instead of having JAXB create a new class in the default package.
How do I do that?
 
Thanks.
Christian