160
Designing XML Based Applications
When you want to implement a flexible mapping design where each
component may manipulate a common document in the most suitable manner
for itself.
When requirements might evolve (such as a new schema to be supported or a
new version of the same schema) to where they would necessitate changes to
the XML processing implementation. Generally, you do not want to alter the
application logic to accommodate these XML processing changes. Addition
ally, since several XML processing APIs (SAX, DOM, XSLT, JAXB technol
ogy, and so forth) may be relevant, you want to allow for subsequent changes
to later address such issues as performance and integration.
When different developer skill sets exist. For example, you may want the busi
ness domain and XML processing experts to work independently. Or, you may
want to leverage particular skill sets within XML processing techniques.
Figure 4.12 and Code Example 4.9 give an example of a supplier Web service
endpoint using an XML document editor to preprocess incoming purchase order
documents.
public class SupplierOrderXDE extends
XMLDocumentEditor.DefaultXDE {
public static final String DEFAULT_ENCODING = "UTF 8";
private Source source = null;
private String orderId = null;
public SupplierOrderXDE(boolean validating, ...) {
// Initialize XML processing logic
}
// Sets the document to be processed
public void setDocument(Source source) throws ... {
this.source = source;
}
// Invokes XML processing logic to validate the source document,
// extract its orderId, transform it into a different format,
// and copy the resulting document into the Result object
public void copyDocument(Result result) throws ... {
orderId = null;
// XML processing...
}
New Page 1