commit | be6d4fdf013290f96184063a48bc45ba6c3b2e40 | [log] [tgz] |
---|---|---|
author | OritMarkus <oritmarkus@gmail.com> | Fri Dec 10 01:18:01 2021 +0200 |
committer | GitHub <noreply@github.com> | Fri Dec 10 00:18:01 2021 +0100 |
tree | d9af7d3cdedbb2079e0e62bd8cc16e6857b57148 | |
parent | c60c3d853277cb4c73a9303a7f56eb8d78124803 [diff] |
fix bug - Marshalling an object that overrides the parent's method, the XML that created contains both child's and parent's tag, the problem was in serializeBody method in the reflection section. the condition should check if the super class contains the declared field that the child overrides. (#1590) * fix bug - Marshalling an object that overrides the parent's method, the XML that created contains both child's and parent's tag, the problem was in serializeBody method in the reflection section. the condition should check if the super class contains the declared field that the child overrides. DTOs: @XmlRootElement(name = "parent") public class ParentDTO { Protected String name; @XmlElement(name= “parentName”) getName) { return name; } setName(String name) { this.name = name; } } @XmlRootElement(name = "child") public class ChildDTO extends ParentDTO { @Override @XmlElement(name="childName") public String getName() { return name; } } Program: Child child = new Child(); child.setName("aaa"); final Marshaller marshaller = JAXBContext.newInstance(ChildDTO.class).createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter stringWriter = new StringWriter(); marshaller.marshal(ChildDTO, stringWriter); String xmlAsString = stringWriter.toString(); XML after Marshall: <child> <parentName> aa </parentName > <childName> aa </ childName > </child>
Jakarta XML Binding gives Java developers an efficient and standard way of mapping between XML and Java code. Java developers using Jakarta XML Binding are more productive because they can write less code themselves and do not have to be experts in XML. Jakarta XML Binding makes it easier for developers to extend their applications with XML and Web Services technologies.
Eclipse Implementation of JAXB enables developers to perform the following operations:
This project is part of Eclipse Implementation of JAXB
Eclipse Implementation of JAXB is licensed under a license - EDL 1.0.
We use contribution policy, which means we can only accept contributions under the terms of Eclipse Contributor Agreement.
Codemodel is an independent library for java code generation, which can be released separately. Besides here it is used in istack-commons-project, which in turn is a dependency of JAXB
XML Schema Object Model (XSOM) is a Java library that allows applications to easily parse XML Schema documents and inspect information in them. It can be released separately to satisfy a dependency of jaxb-fi, which in turn is optional dependency of JAXB
RNGOM and relaxng-datatype under jaxb-ri/external are tools for working with RelaxNG. Both can be released separately to break circular dependency between several jaxb-ri sub-projects including jaxb-ri/xsom above.