The Butler Did It
This chapter is one of the longest in this book and deals with many APIs and concepts. Part of the reason for this is that there has been a great deal of evolution of XML tools over time in order to support working with XML at different levels of abstraction. We’re going to introduce you to the APIs that we think remain important and useful in this chapter and to some extent we’ll do this by starting at the bottom level and working our way up. First we’ll cover basic XML concepts and low-level APIs such as the event-driven SAX (Simple API for Java) and model-building DOM (Document Object Model). We’ll also discuss related technologies such as XML Schema validation, XPath queries, and XSL (Extensible Style Sheet) transformation. Later in this chapter, we’ll discuss the higher-level JAXB, Java XML Binding API, for mapping plain Java objects directly to XML and back.
This means that for some of you, the most useful material may be
toward the end of this chapter where we cover the high-level tools. So we
want to reassure you that things get more interesting as the chapter
progresses. When we reach the section on JAXB we’ll see that we can take
plain old Java objects (POJOs) and write them to XML by adding (in the
simplest case) a one-line annotation. The following snippet shows a Java
Person and Address class and the corresponding XML that
they would map to by default.
@XmlRootElementpublicclassPerson{publicStringname;publicAddressaddress;publicintage;