Chapter 6: Advanced Topics  Directory structure of generated code

Chapter 6: Advanced Topics


The binding framework is implemented in the class called DataBeanOpaque, which represents an XML document. All generated root classes extend class DataBeanOpaque. In addition to providing all methods for serializing and deserializing XML, DataBeanOpaque also provides methods that expose access to the root name and doc type of a particular document instance.

Individual DataBeans use the functionality of the binding framework by extending the class DataBeanOpaque.


The state of DataBeans can be set automatically with the data in an XML instance document. This process is called deserialization. After deserializing, you use accessors and mutators to manipulate the XML document data from Java code.

There are different ways to deserialize XML documents into DataBean instances. The most common way is through the following constructor of a DataBean instance:

RootName(InputStream istrm, boolean validate)

Another way to deserialize XML is by calling the following method on an existing DataBean instance:

void deserializeXML( istrm, boolean validate)

A third way to deserialize XML into a DataBean instance allows the user to do a late binding without incurring the overhead of parsing an XML document twice. This approach is helpful when you require some information from the document instance before determining which particular DataBean instance to bind.

To use this approach, use one of the previous methods to deserialize XML into a DataBeanOpaque object. This object provides methods to retrieve the root name, SYSTEM URI, and PUBLIC URI from the XML document instance. Then, using this information, you can bind a specific DataBean instance one of two ways:

The XML document is parsed only once with this approach.


Serialization allows you to get an XML document directly from the DataBean and use it for your purposes. The data structure from the root class is exported into an XML document through the following method:

void serializeXML( ostrm)


Validation is available through the root class, at the XML-document level. There are two ways to perform a validation. In the first, you use the following constructor:

RootName(InputStream istrm, boolean validate)

If the input XML document does not use a DTD attached and validate = true, an exception is thrown.

Only one exception is thrown in an exception case:


You can use get Message() to get the error information. The error message is usually composed of the class name and function name where the error occurred, as well as a detailed error message.

The second way to perform validation is through a method on the DataBean:

void  iRecipe.validate()

Copyright © 2005. Sybase Inc. All rights reserved. Directory structure of generated code