Want to know, having a class without any annotation, how the jaxb unmarshall the xml data to class.
I found it can take the following
If I have an node "label" in the xml
I have "_label" field in the class and "getLabel" and "setLabel" method.
jaxb can unmarshall it sucsessully. Just want to know its default rule.
@XmlRootElement annotation can be used to map a class or enum type to XML type. When a top level class or an enum type is annotated with the @XmlRootElement annotation, then its value is represented as XML element in an XML document.
In JAXB, marshalling involves parsing an XML content object tree and writing out an XML document that is an accurate representation of the original XML document, and is valid with respect the source schema. JAXB can marshal XML data to XML documents, SAX content handlers, and DOM nodes.
A new Java API called Java Architecture for XML Binding (JAXB) can make it easier to access XML documents from applications written in the Java programming language.
JAXB. JAXB or Java Architecture for XML Binding is the most common framework used by developers to marshal and unmarshal Java objects.
The following is from the JAXB 2 specification (JSR-222):
8.12 Default Mapping
This section describes the default mapping of program elements. The default mapping is specified in terms of default annotations that are considered to apply to a program element even in their absence.
8.12.1 Java Identifier To XML Name
The following is the default mapping for different identifiers:
- class name: a class name is mapped to an XML name by de capitalization using java.beans.Introspector.decapitalize(class name ).
- enumtype name: enumtype name is mapped to an XML name by de capitalization using java.beans.Introspector.decapitalize(enumtype name).
- A property name (e.g. address) is derived from JavaBean access method (e.g. getAddress) by JavaBean de capitalization of the JavaBean property name java.beans.Introspector.decapitalize(JavaBeanAcc essMethod)
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