Portlet Factory, Version 6.1.2


 

About creating your own XML objects and APIs

You can create your own XML representations for any XML document that you want to be able to create and process in your web application models.

For example, if you have a PurchaseOrder XML document that you want to use in your models, you can create a Java class that contains member variables representing the information stored in the Purchase Order and the accessor methods to those variables that provide for the getting and setting of the member values.

Once this class is created, you create a Walker class and a Builder class for it. The Builder class processes SAX events fired as the SAX parser processes the source XML. The Walker class fires SAX events to be processed by an XML Writer class with the end result being an XML representation of the PurchaseOrder object.

To use the new XML object, you could create an empty instance in a method, process the inputs from a page, and set the values of the new object's member variables with the input values. You can call any methods declared in the class you created for the new object, effectively creating your own API for the processing of PurchaseOrder objects. Typically, one of the methods declared in the new class handles the calling of the XML Writer class or any other processing that takes the output of the SAX parser and writes the new XML document.

Parent topic: Overview: working with XML


Library | Support |