Java Reference
In-Depth Information
7.5.1
XML's Golden Hammers
The topic
AntiPatterns
described Golden Hammers, a series of good technolo-
gies employed for ill-suited tasks. In a perceptive paper called “
XML
for Data:
Four Tips for Smart Architecture,” Kevin Williams points out two ways that we
can miscast
XML
. Let's take a look. (For more information, you can see this
paper at www-106.ibm.com
/
developerworks
/
xml
/
library
/
x-xdtips.html.)
XML is not a search engine
XML
provides native searching tools, such as XPath. Even so,
XML
may not be
the best format for data that is subject to extensive searches.
XML
parsing can
be expensive, especially when we're frequently searching for relatively small
fragments or complex relationships in data. We must parse an entire
XML
doc-
ument to perform a reliable search in the proper context. If we intend to
search an
XML
document regularly, it is best to load the document into a tool
built for that purpose—a database, for example. In his article, Williams points
out that the nature of the document should help you make the right decision.
If the document is text oriented, such as a manuscript,
XML
provides a good
native format. If the document is data oriented, like an insurance policy, then a
database would probably be the better option.
XML is a poor choice for large-scale summarizing
For complex data reporting and summarizing purposes, relational database
reporting functions are more powerful than those of
XML
.
XML
also does not
combine documents into intermediate formats as efficiently. However, some
technologies allow indexed
XML
, which
can
provide an effective intermediate
format for communication to a relational database engine. In this way, the two
technologies can be used effectively together.
7.5.2
XML's bitter transitions
When
XML
bridges two subsystems controlled by a single organization, keep-
ing the schema current and each part relevant is easy. Using
XML
documents
across major interfaces presents additional challenges. Table 7.2 shows some
of the areas you must watch. In particular, you should throw away anything
that you are not likely to use, and you should look for data in a structure and
format that it is likely to be used.