|
|
1. How do I convert the contents from a dynamic XML source into Java objects?
It depends on the type of the dynamic XML source that you have.
For example, in the Java Pet Store sample application, we created the PurchaseOrder class and its dependent classes to serialize and deserialize a PurchaseOrder document. We designed these classes to be similar to the classes that the JAXB technology would have generated automatically. This approach is very effective when you have a direct mapping between the schema and the domain object classes.
To isolate the business logic from these details of XML processing, we use helper classes called XML document Editors. These classes are similar to the Data Access Object (DAO) classes but are targeted at editing (creating, assembling, and deassembling) XML documents. These classes are used in several places in the sample application. For example, the supplier application uses the TPASupplierOrderXDE class to validate and transform a TPASupplierOrder document into Java objects. It also uses XSTL to first translate it into a SupplierOrder document conforming to an internal schema. It then uses SAX APIs to extract the OrderId from the incoming document in order to use it as a tracking number. This complex XML processing pipeline is hidden from the business logic using the XDE class since the TPASupplierOrderXDE class only exposes business methods apart from the method to set and get the document.
For more information, read the following document: link
