users@jaxb.java.net

Re: Customize packagae name using external binding file

From: Carlos Alegría <ccristoo_at_gmail.com>
Date: Tue, 5 Feb 2008 09:55:26 -0600

You can do something like this:

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings jxb:version="2.1"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb
http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd">

    <jxb:bindings schemaLocation="adirectory/anSchema.xsd"
        node="/xsd:schema">
 .....
    </jxb:bindings>
    <jxb:bindings schemaLocation="anotherDirectory/anotherSchema.xsd"
        node="/xsd:schema">
 .....
    </jxb:bindings>
</jxb:bindings>

Just keep in mind that you can only use one GlobalBindings element per
compilation, otherwise you will get an error. Also, when running the xjb
command, you will have to add all the schemes mentioned in the xjb file:

xjb adirectory/anSchema another/Directory/anotherSchema - b binding_file.xjb

regards

On Feb 2, 2008 4:06 AM, Deepak Gaikwad <deepakbgaikwad_at_hotmail.com> wrote:

> Thanks carlos,
>
> Yes , your answer will work. But I have many scheam stored under more than
> one folder and I am trying to compile those using only one binding file. It
> is now allowing me do so.
>
> Is there any solution to this ?
>
> Deepak Gaikwad
> Software Engineer
>
>
>
> ------------------------------
> Date: Fri, 1 Feb 2008 10:48:12 -0600
> From: ccristoo_at_gmail.com
> To: users_at_jaxb.dev.java.net
> Subject: Re: Customize packagae name using external binding file
>
>
> Hi,
>
> I'm not sure if this is what you need:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <jxb:bindings jxb:version="2.1"
> xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb
> http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd">
>
> <jxb:bindings schemaLocation="anSchema.xsd"
> node="/xsd:schema">
> <jxb:schemaBindings>
> <jxb:package
> name="a.package.name">
> </jxb:package>
> </jxb:schemaBindings>
> </jxb:bindings>
> </jxb:bindings>
>
> You can find more about the xjb format in the JAXB specification document,
> that can be found here<http://java.sun.com/webservices/reference/apis-docs/index.jsp>
>
>
> On Feb 1, 2008 2:22 AM, Deepak Gaikwad <deepakbgaikwad_at_hotmail.com> wrote:
>
> Hi
>
> I have a scheam file a.xsd and the requirement is to customize the package
> name for the generated classes using external binding file ( .xjb). I am
> using XJC ant task to generate the classes.
>
> Please let me know snippet of the code of the biding file which will
> alllow me to mention the package name
>
>
> Deepak Gaikwad
> Software Engineer
>
>
> ------------------------------
> Fly HYD-BLR for Rs.499 Log on to MakeMyTrip! Check it out!<http://ss1.richmedia.in/recurl.asp?pid=266>
>
>
>
> ------------------------------
> Detailed profiles 4 marriage! Only at Shaadi.com Try it!<http://ss1.richmedia.in/recurl.asp?pid=107>
>