O'Reilly logo

Professional XML by Michael Kay, Kent Sharkey, Sam Ferguson, Alessandro Vernet, Bill Evjen, Thiru Thangarathinam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16. XML and Java

In this chapter, you examine how XML and Java work together. In some ways XML and Java are excellent bedfellows; they're both children of the 1990s and fit in well with modern concepts of Internet and Web-based application architectures, and they both have a solid foundation in Unicode. When it comes to the details, however, there's sometimes a mismatch: For example, the mapping from XML Schema data types to classes in the Java class library is less than perfect.

Java and XML can interact in many different ways. This chapter takes a bottom-up approach, starting with the lowest-level interfaces and working steadily upward. The most important interfaces are covered in detail elsewhere in this book, so this chapter gives more of an overview: a comparative study of the different interfaces, explaining their capabilities and their strengths and weaknesses. Its goal is to enable you to choose the right interface for the job at hand without necessarily providing a detailed reference for each class and method.

At the lowest level, Java applications can read and write lexical XML, that is, XML represented in character form with angle-bracket markup. Reading lexical XML is called parsing; writing lexical XML is called serialization (although that term is overloaded, unfortunately). The first section of the chapter discusses how a Java application can interact with a parser and a serializer.

The next level up is the construction of tree-based representations of XML documents ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required