Java Architecture for XML Binding (JAXB)

XML and Java together are the most ideal building blocks to develop Web services and Applications accessing web services.

Java Architecture for XML Binding (JAXB)

Java Architecture for XML Binding (JAXB)

     

XML and Java together are the most ideal building blocks to develop Web services and Applications accessing web services. XML is considered as the standard for exchanging data across disparate systems and Java provides a platform for building portable applications. One way to access and use an XML document through the Java programming language is through SAX or DOM parsers. Now developers have another Java API which makes it easier to access XML documents: Java Architecture for XML Binding (JAXB). It allows java developer for mapping between the Java classes and the XML representations. JAXB allow us for marshalling of java objects into XML and vice-versa or we can say JAXB enables us to store and retrieve the data in any XML format into the memory. Regularly changing XML schema definitions can be time consuming and error prone so JAXB is useful in such situations.

The general steps to use the JAXB API are:

  1. Bind the schema:
    It requires two steps:
    • Generate classes
    • Compile classes
     
  2. Unmarshal
    It includes the following steps:
    • Generate content tree
    • Validate (optional)
    • Process the content

     

  3. Marshal