Skip to Content
Learning Java, 4th Edition
book

Learning Java, 4th Edition

by Patrick Niemeyer, Daniel Leuck
June 2013
Beginner
1007 pages
33h 32m
English
O'Reilly Media, Inc.
Content preview from Learning Java, 4th Edition

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.

@XmlRootElement
public class Person {
    public String name;
    public Address address;
    public int age;
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Java, 6th Edition

Learning Java, 6th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Head First Java, 3rd Edition

Head First Java, 3rd Edition

Kathy Sierra, Bert Bates, Trisha Gee
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan

Publisher Resources

ISBN: 9781449372477Errata PageSupplemental Content