users@jaxb.java.net

Re: names differing only in case

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 06 Nov 2006 10:40:40 -0800

Johnny Tolliver wrote:
> I have a simple question. It seems that JAXB eschews names that differ
> only in case, forcing me to create customizations for schema over which I
> have no control.

Correct.

> Is this a fundamental "feature" of JAXB because some operating systems
> (names withheld to protect the guilty :-) cannot recognize Java classes that
> differ only in case? So, for example, if a schema contains an element named
> "SomeName" and an attribute name "someName", then there will be an OS file
> system collision between the generated Java classes named SomeName.java and
> someName.java?

Yes.

> And because Java wants to be platform-independent, then XJC insists that it
> be able to generate platform-independent names, meaning names that differ in
> more than just case, because some OSes can't grok file names that differ
> only in case?

I believe the case sensitivity check happens only when you run it on
platforms that has this problem.


> If the above analysis is correct, what is the normal pattern to deal with
> such schema? I've created customization files before -- long ones -- but is
> there some easier way? Barring that, is there some "best practices" pattern
> for doing the customizations?

I'm afraid you'll have to use customizations. If the collision is just
one or two, it shouldn't be too problematic, and there are plenty of
samples bundled with the JAXB RI to show you how.

If your schema systematically exploit such convention, like calling
elements "Foo" and types "foo", then you can use
<schemaBindings>/<nameXmlTransform> to rename all types/elements, etc at
one-go. Again see the bundled examples for how to do this.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com