Hi all! I'm about to customize List property name in the generated code.
For example, we got following schema (fragment):
<xs:complexType name="RecipientList">
<xs:sequence maxOccurs="unbounded" minOccurs="0">
<xs:element name="recipient" type="myns:Recipient">
</xs:element>
</xs:sequence>
</xs:complexType>
In Section 5.5.2.2 of JAXB 2.0 Specification (List Property) it is said:
A list property prop with base type Type is realized by the method
where List
is the interface java.util.List, Id is defined as above.
public List<Type> getId();
So, by default JAXB generates the following property declaration ('Id'
is resolved to the name of element):
protected List<Recipient> recipient;
with following getter:
public List<Recipient> getRecipient() {
...
}
But I think (even though it is in specification) such solution is not so
obvious, and I think it would be better to give name with 's' at the trail:
protected List<Recipient> recipients;
with following getter:
public List<Recipient> getRecipients() {
...
}
To do so I've tried to create external binding to customise property name:
<jxb:bindings node="//xs:complexType[@name='RecipientList']">
<jxb:bindings node=".//xs:element[@name='recipient']">
<jxb:property name="recipients" />
</jxb:bindings>
</jxb:bindings>
But XJC compiler give following error:
[ERROR] compiler was unable to honor this property customization. It
is attached to a wrong place, or its inconsistent with other bindings.
Could someone tell how to fix it?
Maybe there is another way to solve my problem?
Thanks in advance. :)
--
Pharmanet, Cubus Team