mardi 3 mars 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:


EDIT - adding namespace definitions



...
xmlns:def="http://ift.tt/1E1vTOq"
xmlns:abc="http://ift.tt/1APtT8j"
...
<xsd:import namespace="http://ift.tt/1APtT8j" schemaLocation="ABCXMLResponse.xsd"/>
<xsd:import namespace="http://ift.tt/1E1vTOq" schemaLocation="DEFXMLResponse.xsd"/>
...
<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 ABCProducts 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