Tuesday, August 02, 2005

JAXB and Castor ( no Pollux :( here )

JAXB and Castor are APIs that facilitate reading XML documents and mapping the content into java objects.

JAXB procedure


A schema definition document (.xsd) has to be made, which when ‘bind’ed to the API will create the java objects that need to be filled with the contents of the XML file.

It’s NOT possible to create your own classes, however you can modify the classes that the API generates by specifying options during binding.

Castor procedure


The java objects that need to be filled with the contents of the XML file, can be created by the user (this gives a lot flexibility when compared to JAXB), or they can be generated by the Sourcegenerator JAR.

The main difference is that this method does not need an XML schema definition. But we will need a mapping document for that purpose. The mapping document can also be generated using tools like org.exolab.castor.tools.MappingTool or 3rd party tools.

No comments:

Post a Comment