O'Reilly logo

Java EE Development with Eclipse by Deepak Vohra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Marshalling an XML document

In this section we marshal a Java representation of an XML document constructed using the compiled Java classes to an XML document. Create the Java class by going to File | New | Other and selecting Java | Class. Provide a JAXB context for implementing the JAXB framework with a JAXBContext object. Create a Marshaller object from the JAXBContext object and set the jaxb.formatted.output to true. The newInstance() static method of the JAXBContext class takes a list of packages, separated by a colon (:), that are to be added to the JAXB context. A package to be added to the JAXB context must contain either an ObjectFactory class or a jaxb.index file. As we compile the catalog.xsd XML Schema into the jaxbeclipse package, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required