Chapter 4 XML Processing
173
By definition, XSLT supports not only processing XML input documents but
it also can output XML documents. (Other output methods include text, HTML,
and so forth.) Note that although the DOM version level 2 API does not support
serialization that is, transformation of a DOM tree to an XML document the
JAXP implementation of XSLT addresses the serialization of a DOM tree using
an identity transformer. An identity transformer copies a source tree to a result
tree and applies the specified output method, thus solving the serialization
problem in an easy, implementation independent manner. For example, to output
in XML, the output method is set to
xml
. XSLT can also be used to serialize to
XML from DOM trees, SAX events, and so forth.
Consider using XSLT when any of the following circumstances apply:
E
You want to change the structure, insert, remove, rename, or filter content of
an XML document.
E
You potentially have more than one transformation for the same document. Al
though one transformation can be hand coded using another API, multiple
transformations, because of the scripting nature of style sheets, are better done
using XSLT transformations.
E
You have to perform complex transformations. Because of XSLT's functional
declarative model, it is easier to design complex transformations by coding in
dividual rules or templates than by hard coding procedures.
E
You want the ability to be flexible and leave room for future changes in the
schemas of documents you are processing.
E
You want to process documents that contain a significant amount of data to
minimize performance overhead.
E
You need to transform a document for non interactive presentation or in batch
mode. The performance overhead of transformation is usually less of an issue
with non interactive presentations. Such a document might be a purchase order
or an invoice, for example.
E
You must support multiple external schemas but you want to internally pro
gram only against a generic schema (schema adapter).
New Page 1