Actually, Doing to Make the Jaxb Object like JAXBContext is too heavy task to computer. so I recommend to use the code related to ‘JAXBContext’ separately when you make it.
I proposed the above xml file for understanding the process to make the VO file when you use JAXB Marsharlling, UnMarshalling. It has various type of the data like List, the nested VO Object , Default type data.
4. Create the VO files.
Importantly, JAXB can’t parse any data partly. If you want to get some data from the api written by xml, then you should take all of the xml api without any the skip. In the above sample xml data, You should make 3 VO files totally. They are the parent node of the sample xml data.
These 3 VO files are exactly expressed to XML data.
@XmlRootElement this annotation is for expressing the each root node of the xml. and the annotation can has the ‘name’ attribute. It’s for occuring the exactly xml tag name. If the names are different between POJO and XML then JAXB can’t parse. then This annotation throw the exception of JAXB.
@XmlElement this annotation is for the each filed of the JAXB VO classes. It also can has the ‘name’ attribute, This attribute is the role for connection between POJO variable name and XML tag name like the @XmlRootElement annotation. If those names are not same then the field will have the null value.
@XmlAccessorType(XmlAccessType.FIELD) It’s for definition of the namespace when you parse the data using JAXB. If you don’t use this annotation then maybe your jaxb vo fields are overlapped.