The following test that I provide runs under WildFly 13 (JEE 7 / JAXB v2.2) correctly. Under WildFly 19 (JEE8 / JAXB v2.3) fails with the erroneous output that I attach.
@Test
public void test_marshaller() throws JAXBException {
SPC spc = new SPC();
spc.setAdminInfo(new AdminInfo());
spc.getAdminInfo().setAuthorisation(new Authorisation());
spc.setLang(LanguageCode.valueOf("en"));
JAXBContext context = JAXBContext.newInstance(SPC.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
System.out.println("Marshaller package is " + Marshaller.class.getPackage());
System.out.println("Marshaller generic string is " + marshaller.getClass().toGenericString());
System.out.println("Marshaller class Name is " + marshaller.getClass().getName());
System.out.println("Context Name is " + context.getClass().getName());
marshaller.marshal(spc, System.out);
}
Under WF 13 I receive the following correct output:
<ns4:SPC xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.w3.org/1999/xhtml" xmlns:ns4="http://echa.europa.eu/schema/spc/1.0/" xml:lang="en">
<ns4:AdminInfo>
<ns4:Authorisation>
<ns4:Date xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<ns4:Expiry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</ns4:Authorisation>
</ns4:AdminInfo>
<ns4:AuthorisedUses/>
</ns4:SPC>
and under WF 19 I receive the following erroneous output:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns4:SPC xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://www.w3.org/1999/xhtml" xmlns:ns4="http://echa.europa.eu/schema/spc/1.0/" xml:lang="en">
<ns4:adminInfo>
<ns4:Authorisation>
<ns4:Date xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<ns4:Expiry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</ns4:Authorisation>
</ns4:adminInfo>
<ns4:lang>
<representation>en</representation>
</ns4:lang>
<ns4:AdminInfo>
<ns4:Authorisation>
<ns4:Date xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<ns4:Expiry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</ns4:Authorisation>
</ns4:AdminInfo>
<ns4:AuthorisedUses/>
</ns4:SPC>
Please note the adminInfo
& AdminInfo
.
I would like to have only one node starting with capital letter.
Any ideas what could raise the duplicate elements?
--- UPDATE ---
I generate the SPC through an XSD with the help of this maven plugin:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.9.1</version>
<configuration>
...
<plugins>
<plugin>
<groupId>com.github.jaxb-xew-plugin</groupId>
<artifactId>jaxb-xew-plugin</artifactId>
<version>1.6</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.9.0</version>
</plugin>
</plugins>
</configuration>