When Not to Use Either


If the task to be performed and the XML data are simple, there usually is no need to use an XML parser; a java.io.StreamTokenizer would suffice. For example, if the task is to read a file and replace a known element value with another, it can be done more quickly, with fewer resources, using Strings rather than SAX and DOM.

The premise that everything must be XML is fundamentally flawed. A common misuse of DOM is reasoning on the following lines. "I'm developing EJBs that will be exposed as services and called by other EJBs across a tier. Therefore, the data passed between them should be XML, and a DOM Document object is best suited for this purpose." Or "My Servlet tier and EJB tier are distributed; therefore, I should use XML for communication between them." While it is true that XML is a portable data format, it is usually not the best choice to communicate with tiers of the same application that never integrate with other applications (see Chapter 2). It is also not the best choice for practical reasons, such as processing, encoding, overheads, and network bandwidth.




Java Web Services Architecture
Java Web Services Architecture (The Morgan Kaufmann Series in Data Management Systems)
ISBN: 1558609008
EAN: 2147483647
Year: 2005
Pages: 210

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net