users@jaxb.java.net

Re: Working with multiple vendor files - How To

From: Sekhar Vajjhala <sekhar.vajjhala_at_sun.com>
Date: Wed, 02 Jul 2003 06:41:00 -0400

"Pratt, Jerald" wrote:

> Brian,
>
> Good info. I've always used the "-p" option and didn't realize that w/out
> it I could actually get separate packages. My problem is that I want to
> control the package names and not use any default naming that might be
> assumed from the namespace. But, as you mentioned, it sounds like I can so
> this with a binding file. I guess its time for me to take JAXB to the next
> step and figure out binding files.

The <package> customization in the <schemaBindings> can be either inline
or external (in an external binding file).

The sample inline_customize/po.xsd in the samples directory contains
an example of the inline <package> customization.

The sample external_customize/binding.xjb in the samples directory contains
an example of the <package> customization.

Sekhar Vajjhala
Sun Microsystems

>
>
> Jerald
>
> -----Original Message-----
> From: Franklin, Brian [mailto:brian.franklin_at_ciraden.com]
> Sent: Friday, June 27, 2003 12:06 PM
> To: JAXB-INTEREST_at_JAVA.SUN.COM
> Subject: Re: Working with multiple vendor files - How To
>
> You are correct about the differences.
>
> Typically, as you may know, the targetNamespace in a given schema is used to
> determine the package for the classes generated from that schema. When
> giving my one-liner piece of advice, I made the assumption that the schemas
> you were importing had their own unique namespaces, and thus would be bound
> into different packages. But if they have no targetNamespace, then
> obviously this wouldn't work. Also, if you specify -p [package name] when
> invoking XJC, I believe this overrides the normal functionality and will
> place all generated classes into the single specified package no matter what
> the targetNamespaces are.
>
> So, now for the practice advice part... No matter what the case, one way to
> help be sure about the behavior is to use the<package> customization under
> <schemaBindings> (see the JAXB spec section 6.6.1.1) to specify the package
> for each schema, and don't use -p on the XJC command line.
>
> Sorry I wasn't more verbose/thorough to begin with...Cutting corners and all
> that. Let me know if that helps,
>
> Brian
>
> -----Original Message-----
> From: Pratt, Jerald [mailto:jerald.pratt_at_ngc.com]
> Sent: Friday, June 27, 2003 2:19 PM
> To: JAXB-INTEREST_at_JAVA.SUN.COM
> Subject: Re: Working with multiple vendor files - How To
>
> Brian,
>
> I have use both <import> and <include> w/in my schemas and compiling these
> with xjc will always create one large package as opposed to varioius
> separate packages that can call on one another. Also, the differences
> between <import> and <include> don't really make them interchangible. I
> could be wrong, but I believe you use <import> when referencing a separate
> namespace where as you use <include> when you are simply adding to your
> current namespace (but maybe my view of this is too simplistic).
>
> Jerald
>
> -----Original Message-----
> From: Franklin, Brian [mailto:brian.franklin_at_ciraden.com]
> Sent: Friday, June 27, 2003 11:19 AM
> To: JAXB-INTEREST_at_JAVA.SUN.COM
> Subject: Re: Working with multiple vendor files - How To
>
> I think you may want to use <import> rather than <include>.
>
> Brian Franklin
>
> -----Original Message-----
> From: Hank Ratzesberger [mailto:hankr_at_crustal.ucsb.edu]
> Sent: Friday, June 27, 2003 11:54 AM
> To: JAXB-INTEREST_at_JAVA.SUN.COM
> Subject: Re: Working with multiple vendor files - How To
>
> Koshuke,
>
> Let me try again, thank you.
>
> I have several complex schemas from other vendors
> (mostly ISO and OpenGIS) which I would like to
> place in their own packages.
>
> These files <include> each other, so when I
> generate the classes, I get one big package.
> (They are distributed this way, and I simply
> used them.)
>
> Perhaps what I need to do is remove the <include>
> and use the catalog to instruct xjc where the
> schemas are to resolve dependencies at runtime.
>
> Basically, I don't want to end up with one
> huge package.
>
> --Hank
>
> ----- Original Message -----
> From: "Kohsuke Kawaguchi" <Kohsuke.Kawaguchi_at_Sun.COM>
> To: <JAXB-INTEREST_at_JAVA.SUN.COM>
> Sent: Friday, June 27, 2003 8:24 AM
> Subject: Re: Working with multiple vendor files - How To
>
> > I'm sorry, but I don't understand your question.
> >
> > Hank Ratzesberger <hankr_at_crustal.ucsb.edu> wrote:
> > > I am sure what the best method is to working
> > > with multiple schemas. I experimented with a
> > > binding solution that separated the classes
> > > into packages based on the namespace URI
> > > automatically. This allowed me to directly
> > > include xsd files (indeed it was required in
> > > order to resolve all entities to primitives).
> > >
> > > With JAXB, only one is created for each
> > > compilation.
> > >
> > > Do I remove the <import> statements and
> > > rely on the cataloging feature, then make
> > > a separate build for each schema?
> > >
> > > Thanks in advance for any tips on a
> > > method/methodology of working with JAXB
> > > and third party published schemas.
> > >
> > > Regards,
> > >
> > > ============================================
> > > Replying to a list? I'll get my copy there!
> > >
> > > Hank Ratzesberger
> > > http://crustal.ucsb.edu/ | http://neesgrid.org/
> > > Institute for Crustal Studies
> > > University of California, Santa Barbara
> > > ============================================
> >
> >
> > regards,
> > --
> > Kohsuke Kawaguchi 408-276-7063 (x17063)
> > Sun Microsystems kohsuke.kawaguchi_at_sun.com
> >