Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the default rule for jaxb unmarshall the xml data?

Tags:

java

jaxb

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.

like image 689
user496949 Avatar asked Mar 05 '11 11:03

user496949


People also ask

Which tag represents the root element for the XML document in JAXB?

@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.

How does JAXB marshalling work?

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.

What binding means JAXB Mcq?

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.

Which Java classes do we use to Unmarshall information from a file and into in memory objects?

JAXB. JAXB or Java Architecture for XML Binding is the most common framework used by developers to marshal and unmarshal Java objects.


1 Answers

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)
like image 96
bdoughan Avatar answered Oct 20 '22 00:10

bdoughan