Given a .xsd
file, I had the strategy to use a Maven tool to generate Java classes from this, and then use Jackson to serialize the data.
I'm using:
org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.3
to generate the Java classescom.fasterxml.jackson.dataformat.xml.XmlMapper
(2.9.2) withnew JaxbAnnotationModule()
to serialize
Example of generated code:
@XmlElement(required = true)
protected List<TLocalizedString> title;
Example of usage:
TLocalizedString tls = new TLocalizedString();
tls.setValue( string );
tls.setLocale( LOCALE );
item.getTitle().add( tls );
We are getting:
<item ....>
<title>
<title locale="en_US">The Title</title>
</title>
What we expected:
<item ....>
<title locale="en_US">The Title</title>
In other words the XML is coming out nested.
Is this something that should be controlled:
- In the code at point of usage?
- In the config for the Jackson serializer?
- In the code generation via config or generation flags?
- In the code generation via
.xsd
changes?