+

Search Tips   |   Advanced Search

Use the JAXB runtime to marshal and unmarshal XML documents


Use the Java™ Architecture for XML Binding (JAXB) run time to manipulate XML instance documents.

Use JAXB to generate Java classes from an XML schema with the schema compiler, xjc command or to generate an XML schema from a Java class with the schema generator, schemagen command.

Use JAXB APIs and tools to establish mappings between an XML schema and Java classes. After data bindings exist, use the JAXB binding runtime API to convert XML instance documents to and from Java objects.

Data stored in an XML document is accessible without the need to understand the data structure. JAXB annotated classes and artifacts contains all the information that the JAXB runtime API needs to process XML instance documents. The JAXB runtime API enables marshaling of JAXB objects to XML and unmarshaling the XML document back to JAXB class instances.

 

 

Results

We can now marshal JAXB Java classes, and unmarshal XML data using the JAXB binding framework. Refer to the JAXB 2.0 Reference implementation documentation for additional information about the marshal and unmarshal runtime APIs

If Java 2 Security is enabled, wrap the JAXBContext.newInstance(), Unmarshaller.unmarshal() and, Marshaller.marshal() method calls within a AccessController.doPrivileged method to avoid a security exception. gotcha .


JAXB

 

Related tasks


Use JAXB for XML data binding
Use JAXB tools to generate an XML schema file from a Java class
Use JAXB tools to generate JAXB classes from an XML schema file
Set the was.policy file for Java 2 security

 

Related


Web services specifications and APIs

 

Related information


JAXB 2.0 Reference implementation
JAXB 2.0 RI Vendor Extensions Runtime Properties spec
JAXB 2.0 spec documentation