users@jaxb.java.net

Re: Collision problems

From: Sekhar Vajjhala <Sekhar.Vajjhala_at_Sun.COM>
Date: Fri, 24 Mar 2006 07:09:57 -0500

Andreas Pakulat wrote:

> Hi,
>
> I have a bunch of collisions here because the schemas I use define
> types with a name of "_<sometypename>" and also types that use
> "<sometypename>". I can't change the schemas and trying to do this
> with underscoreBindings="asCharInWord" didn't work out.

Try using the above customization with nameXmlTransform
as shown below. The _ will be preserved, and you will
get the java types : My_Person and MyPerson.

--------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xsd:schema version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
            jxb:version="2.0">
  <xsd:annotation>
    <xsd:appinfo>
      <jxb:schemaBindings>
        <jxb:nameXmlTransform>
             <jxb:typeName prefix="My"/>
        </jxb:nameXmlTransform>
      </jxb:schemaBindings>
    </xsd:appinfo>
    <xsd:appinfo>
      <jxb:globalBindings
           underscoreBinding="asCharInWord"/>
    </xsd:appinfo>
  </xsd:annotation>

  <xsd:complexType name="_Person">
    <xsd:sequence/>
  </xsd:complexType>

  <xsd:complexType name="Person">
    <xsd:sequence/>
  </xsd:complexType>

</xsd:schema>
-----------------------------------------------------------------

The prefix specified in jxb:typeName applies to all the
schema types within the targetNamespace to which
the <schemaBindings> applies.

If the above is not suitable solution, then you can try the
<jxb:class> customization which allows you customize
the name of the generated classes/interfaces.

If you cannot modify the schema, use the external binding
schema syntax.

If none of the above is a suitable solution, you can write a
plugin.

Sekhar

>
>
> Is there another way to solve this, other than writing a plugin to
> change a class name of "_<something>" to something like
> "Underscore<Something>"?
>
> Andreas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>