jeudi 26 février 2015

JAXB and matching property names



I am trying to use the XJC utility to generate classes from an XSD file. It works OK except when looking into my generated class i get:



* You are getting this "catch-all" property because of the following reason:
* The field name "Products" is used by two different parts of a schema. See:
* LINE 16 of FILENAME.xsd
* line 15 of FILENAME.xsd


Looking at the xml:



<xsd:choice minOccurs="0">
<xsd:element name="HostResponse" type="xsd:string"/>
<xsd:element ref="abc:Products"/>
<xsd:element ref="def:Products"/>
</xsd:choice>


How using bindings can I tell it to make two properties, one called ARFProducts and one called DEFProducts?


My attempt below is not-working:



<jaxb:bindings schemaLocation="FILENAME.xsd">
<jaxb:bindings node="//xs:choice">
<jaxb:bindings node=".//xs:attribute[@ref='abc:Products']">
<jaxb:property name="ABCProducts"/>
</jaxb:bindings>
<jaxb:bindings node=".//xs:attribute[@ref='def:Products']">
<jaxb:property name="DEFProducts"/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>


What might I be doing wrong?




Aucun commentaire:

Enregistrer un commentaire