JAXB simple binding mode modifies collection names to their plural 'version', e.g. "additionalData" becomes "additionalDatas". Is there any solution to change this behavior? I need to have a Java field name and methods name equal to XSD field name. My bindings file:
<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xsi:schemaLocation="
http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
version="2.1">
<globalBindings>
<serializable uid="1" />
<xjc:simple/>
</globalBindings>
</bindings>
7.1. The JAXB-2 Maven plugin uses the JDK-supplied tool XJC, a JAXB Binding compiler tool that generates Java classes from XSD (XML Schema Definition). By default, this plugin locates XSD files in src/main/xsd.
JavaTM Architecture for XML Binding (JAXB) provides an API and tools that automate the mapping between XML documents and Java objects. JAXB makes XML easy to use by compiling an XML schema into one or more Java technology classes.
XJC is a Java SE tool that compiles an XML schema file into fully annotated Java classes. It is distributed within the JDK package and is located at /bin/xjc path.
Old JAXB XJC Contains source code needed for binding customization files into java sources. In other words: the *tool* to generate java classes for the given xml representation.
The "simple binding mode" is an extended feature of the JAXB RI (Metro). Making the collection property names plural was part of its design.
From: http://weblogs.java.net/blog/kohsuke/archive/2007/01/using_jaxb_ris.html
My favorite feature in the JAXB RI is the simpler and better binding mode, which makes the generated code even easier to use, by ...
- Eliminating JAXBElement as much as possible
- Giving you a better, more typed binding in general
- Use plural property names where applicable
You may be able to use the normal schema customizations to control the property name. Refer to one of my previous answers (link below):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With