Unmarshalling an XML document is when you create a Java representation of an XML document and, subsequently, retrieve element and attribute values in the XML document.
To understand how to process XML documents in Java with JAXB 2.0, here's a closer look at the two main JAXB components: the binding compiler (which binds a given XML schema to a set of generated Java classes) and the binding runtime framework (which provides unmarshalling, marshalling, and validation functionalities).
This is a sample XML document that I will process: This will generate a set of Java classes annotated with JAXB 2.0 annotations.
Binding runtime framework To unmarshall an XML document, you create an unmarshaller from the context.
Marshaller marshaller = jaxb Context.create Marshaller(); ....
JAXBElement JAXB 2.0 simplifies the use of XML content in Java applications.
Object Factory factory = new Object Factory(); Ticket booking = factory.create Ticket(); ....JAXB does this by specifying a binding between an XML document and Java Beans technology components based on the XML document's XSD schema.If you want to learn more about this topic, I recommend that you check out the Get Java tips in your inbox Delivered each Thursday, our free Java newsletter provides insight and hands-on tips you need to unlock the full potential of this programming language. The binding is easy to use and natural to a Java programmer.
These APIs have been used to successfully process some large, well-known schemas.
Binding compiler The JAXB binding compiler (or xbj) lets you generate Java classes from a given XML schema.