users@jaxb.java.net

Re: XCJ naming collision with Attributes and Elements

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Mon, 19 May 2008 10:46:01 +0200

Hi.
>
> Sorry if this is a FAQ, but I cannot seem to find a general simple answer.
>
> I have schema from a standards body that defines an element named row.
> Later on there is an attribute on an different element that is also named
> row. This causes xjc to fail with the error: Property "Row" is already
> defined .....
>
> This schema in question is part of a set of schemas form the OGC that
> defines gml.
>
> A few points of interest:
>
> I am using the latest released version of JaxB.
>
> I cannot change the xsd file.
>
> It happens in many files that are included from several different schemas,
> so that making a binding entry in a bindings file for each occurrence would
> be painful at best (as well as error prone).
>
> I was hoping for a general solution such as adding an attribute to the
> global bindings in my bindings file, but so far have not had much luck.
>
> Many thanks in advance!

You may be interested in the https://ogc.dev.java.net/. The project
compiles almost all of the OGC schemas with JAXB. Including GML.

Concerning your question, you have to customize the schema using the
external binding file like this one:

        <jaxb:bindings
                schemaLocation="gml/3.1.1/smil/smil20.xsd"
                node="/xs:schema">
                <jaxb:schemaBindings>
                        <jaxb:package name="org.w3.smil.v_2_0"/>
                </jaxb:schemaBindings>
                <jaxb:bindings
node="xs:attributeGroup[@name='structureModuleAttrs']/xs:attribute[@name='class']">
                        <jaxb:property name="ClassName"/>
                </jaxb:bindings>

        </jaxb:bindings>


Bye.
/lexi