The JAXP package is a set of Java classes that implements XML document parsers,
supplies methods that can be used to manipulate the parsed data, and has special
transformation processors to automate the conversion of data from XML to another
form. For example, the other form can be a database record layout ready for storage, an
HTML Web page ready for display, or simply a textual layout ready for printing.
One of the outstanding features of XML is its fundamental simplicity. Once you un-
derstand how tags are used to create elements, it is easy to manually read and write
XML documents. With this basic XML understanding, and with knowledge of the Java
language, it is a straightforward process to understand the relationship between XML
and the Java API for manipulating XML. There are only a few classes in this API, and
it is only a matter of creating the appropriate set of objects, and they will supply the
methods you can call to manipulate the contents of an XML document. With these basic
concepts understood, and with the simplicity of the constructs involved, you can de-
sign and write programs while concentrating mostly on the problem you are trying to
solve, not on the mechanics of getting it done.
Java, the Language
Following are some characteristics of Java that make it ideal for use as a language to
manipulate XML documents:
n
The JAXP is now a part of standard Java. It contains all of the classes and inter-
faces that you need for parsing and processing an XML document. It also con-
tains methods that can be used to automate the transformation process of
converting an XML document into an entirely different form.
n
The fundamental Java stream IO can be used for input of XML documents and
output of the results of processing. This means that your application is able to
process files stored remotely on the Internet just as easily as the ones on the local
disk. Once a stream has been established to a file, the rest of the application can
use streaming input and output without having to know anything about the lo-
cation at the other end of the stream. You can write your application just once
and know that it will work no matter how the data needs to be fed to or extracted
from it.
n
The majority of installed Web servers are capable of running Java applications
to dynamically generate Web pages. This means that, using the JAXP, the set of
Java classes that provide the methods to be used to manage XML documents, it
becomes a very simple matter to transform data from an XML format to HTML
format as a response to a request made from a remote Web browser. All of the
software you need, from receiving the request through formatting the data to
transmitting the response, is ready and waiting. About all that is left to do is de-
cide how you want the Web page to appear and then write the Java code to lay
it out.
n
Portability applies to anything written in Java. Using Java and its built-in JAXP
allows you to run the application on any computer that has a Java Virtual Ma-
2
Chapter 1
3851 P-01 1/28/02 10:32 AM Page 2