users@jaxb.java.net

Re: XJC : Leading Underscores and underscoreBinding

From: Ryan Shoemaker - JavaSoft East <Ryan.Shoemaker_at_sun.com>
Date: Wed, 25 Jun 2003 17:47:42 -0400

Hank Ratzesberger wrote:

>
>
> There is, however, a name collision for the element "_Surface"
> because the class "Surface" also exists. Indeed, GML
> does this for many, many elements, creating abstract versions
> with "_" .
>
> I have worked around this problem by specifically binding
> that classname, but I wonder if this should be considered a
> bug -- it appears that leading underscores are ignored regardless
> of underscoreBinding.
>

I'm not seeing the same behavior (unless I'm misunderstanding the problem).
Take a look at the attached schema and binding customization. I declare
two elements "_foo" and "foo" - xjc handles them exactly as the spec says
it should with no name collisions, generating _foo.java and Foo.java. All
of the generated code compiles under javac as well.

Please modify the sample schema to reproduce the problem and send it back
to the list....

> Apologies if I missed this in the documentation, but I only
> detected a conflict between _ and the specification of a
> java identifier.
>

I'm not exactly sure what you mean by this...

Thanks,

--Ryan


<jaxb:bindings version="1.0"
              xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
              xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <jaxb:bindings schemaLocation="foo.xsd" node="/xs:schema">
        <!-- see JAXB Specification sec 6.5 for more detail -->
        <jaxb:globalBindings
            fixedAttributeAsConstantProperty="true"
            collectionType="indexed"
            typesafeEnumBase="xs:string"
            choiceContentProperty="false"
            typesafeEnumMemberName="generateError"
            bindingStyle="modelGroupBinding"
            enableFailFastCheck="false"
            generateIsSetMethod="false"
            underscoreBinding="asCharInWord"/>
    </jaxb:bindings>
</jaxb:bindings>