152
Designing XML Based Applications
separation between business and XML programming skills, especially when an
application developer who is more focused on the implementation of the business
logic must additionally master one or several of the XML processing APIs.
There are cases that require a document centric processing model, such as:
The schema of the processed documents is only partially known and therefore
cannot be completely bound to domain specific objects; the application edits
only the known part of the documents before forwarding them for further pro
cessing.
Because the schemas of the processed documents may vary or change greatly,
it is not possible to hard code or generate the binding of the documents to do
main specific objects; a more flexible solution is required, such as one using
DOM with XPath.
A typical document centric example is an application that implements a data
driven workflow: Each stage of the workflow processes only specific information
from the incoming document contents, and there is no central representation of the
content of the incoming documents. A stage of the workflow may receive a docu
ment from an earlier stage, extract information from the document, apply some
business logic on the extracted information, and potentially modify the document
before sending it to the next stage.
Generally, it is best to have the application's business logic directly handle
documents only in exceptional situations, and to do so with great care. You should
instead consider applying the application's business logic on domain specific
objects that completely or partially encapsulate the content of consumed or pro
duced documents. This helps to isolate the business logic from the details of XML
processing.
Keep in mind that schema derived classes, which are generated by JAXB and
other XML data binding technologies (see XML Data Binding Programming
Model on page 169), usually completely encapsulate the content of a document.
While these schema derived classes isolate the business logic from the XML pro
cessing details specifically parsing, validating, and building XML documents
they still introduce strong dependencies between the business logic and the
schemas of the consumed and produced documents. Because of these strong
dependencies, and because they may still retain some document centric character
istics (especially constraints), applications may still be considered document
centric when they apply business logic directly on classes generated by XML
New Page 1