Introduction

XML Development with Java™ 2

"The first step is putting data on the Web in a form that machines can naturally understand, or converting it to that form. This creates what I call a Semantic Web—a web of data that can be processed directly or indirectly by machines."

—Tim Berners-Lee, Weaving the Web

Welcome to XML Development with Java 2. This book provides an in-depth guide to developing XML applications with Java. The topics cover implementing XML standards, such as DOM and XSL, in Java, and exploring XML's influence on Java libraries such as Swing and JavaBeans. In addition, nontrivial examples demonstrate all the topics with complete working programs. Last, a building-block approach gets you up and programming quickly and then follows through later with details on the less common features of the standards.

This book assumes that you are familiar with the basics of programming Java. We do not assume you are familiar with XML and walk through all aspects of the key standards. If you are familiar with XML, you can skip over the chapters that teach the basics and focus on the more advanced topics like parsing, XSLT, and EJB integration. Also, this book does not attempt to cover all the XML standards as some are still in flux (or have no implementation) and others are applications of the base standards (such as the Math Markup Language).

Why XML?

Tim Berners-Lee, the inventor of the World Wide Web, hopes to see his creation change in two ways: first, to become more collaborative and, second, to move from presentation to multipurpose processing. While a more collaborative Web requires browsers to morph into full-scale multimedia editors, the second change to the Web requires reengineering of the lingua franca of the Web. In other words, where HTML is a presentation language, the next-generation Web requires a richer communication set that can be automatically processed by computers, traveling software agents and end-user browsers (hopefully of the multimedia-enriched, collaborative kind). So, the key idea is that the next-generation Web will be as easily traversable by computer programs as it is surfed by browsers.

The second-generation Web is approaching and XML is the engine that will take us there. It is not a question of whether XML will become pervasive on the Web but how quickly it will happen. XML's first beachhead will be business-to-business commerce and from there it will spread throughout the entire Web, eventually creating new concepts, opportunities and extrapolated technologies. Now is the time for you to become proficient in XML development to be on the forefront of this technological wave.

Why XML with Java?

Request for Comments (RFC) 2396 describes the syntax of Uniform Resource Identifiers (URIs), which are related to Uniform Resource Locators (URLs). However, the original name of these resource descriptions was Universal Resource Identifiers. The goal was and is clear: a universal information space. An information space not confined to one type of computer, one type of application, or one geography. The World Wide Web consortium is, in essence, handling the data side of this information space. The applications to take advantage of this universal information space are left up to the software industry. This is where Java becomes the most obvious choice for an implementation vehicle. Java was designed to be a network-savvy universal computing platform. Thus Java aids the adoption of XML by providing implementations that can run anywhere.

Another theoretical example of the affinity of Java and XML is they both represent implementations of user-defined versus technological-defined goals. In other words, both put accomplishing a user-defined task above operating efficiently on computing hardware. Java's interpreted code provides the user benefit of write once, run anywhere. XML's human-readable "text as data" prescription provides the user benefit of application independence. Both have purposely sacrificed computing efficiency for user-defined goals. This is why many people proclaim the convergence of these technologies as nothing short of a technological revolution.

A more practical reason for processing XML with Java is that Java has established itself as the de facto standard for server side computing. So, as XML becomes the de facto standard for storing corporate data, that data will be manipulated, stored and transformed by Java enterprise programs.

Organization of the Book

This book is organized in two ways: The first part of the book follows a loose building-block sequence and the rest covers key topics but in no particular order.

The individual chapters in the book are

  • Chapter 1, "An XML Primer" —Walks you through the basics of creating XML documents. Detailed examples demonstrate each component of an XML document. This chapter quickly gives you the basics necessary to understand the key parts of an XML document that you will want to parse for use in a Java application. The key idea is that you need to know just enough XML to get to parsing XML documents.

  • Chapter 2, "Parsing XML" —Covers parsing XML documents in detail for both Java applications and applets. The chapter focuses on the two most prevalent standards for parsing: SAX and the javax.xml standard extension. Includes a detailed discussion of the Aelfred parser that is specifically designed to be fast and small. Aelfred is perfect for applets.

  • Chapter 3, "The Document Object Model (DOM)" —This chapter covers the DOM specification and several implementations. Covers both traversing a DOM and creating a DOM structure from scratch.

  • Chapter 4, "Advanced XML" —This chapter fills in all the details of the XML Specification glossed over in Chapter 1. In addition, it covers new and emerging XML areas such as namespaces, XLINK, and XPointer.

  • Chapter 5, "Java and the Extensible Stylesheet Language (XSL)" —This chapter covers both the XSL Transformation specification and the XSL Formatting objects specification. Includes demonstrations using several XSLT processors such as XT, LotusXSL, and Microsoft Internet Explorer. Includes numerous style sheet examples covering every major feature of the specification.

  • Chapter 6, "Collections and XML" —Introduces the Java collection classes and their similarity to the DOM, then examines how to integrate the DOM with Java's built-in collection classes. Also demonstrates sorting a DOM.

  • Chapter 7, "Swing and XML" —Covers the interaction between Swing and XML in the areas of DOM viewing and GUI construction. Demonstrates how to view a DOM using a JTree and a JTable. Demonstrates how simple XML-based markup languages can ease GUI constructions. Demonstrates a simple menu markup language to quickly build menus.

  • Chapter 8, "JavaBeans, EJB, and XML" —Covers both JavaBeans and Enterprise JavaBeans. For JavaBeans, demonstrates saving state via XML and XML for Bean composition. For Enterprise JavaBeans (EJB), provides a thorough introduction and exploration of the EJB architecture before examining how XML can be used for Bean-managed persistence.

  • Chapter 9, "Servlets and XML" —Introduces the basics of servlets programming before discussing its integration with XML. Uses a real-world example, an aphorisms Web site, to demonstrate the key concepts. The site collects and displays aphorisms. To accomplish this, we cover converting form data inputs to XML, storing XML, and transforming XML to HTML.

  • Chapter 10, "XML and Database Access" —This chapter covers the integration of relational databases and XML. The topics range from techniques you can implement today to emerging technologies of tomorrow. First, we cover how to map relational databases to XML. Second, we explain how Oracle integrated XML into Oracle 8i. Last, we cover the current state of the XML Query language specification.

Comments Welcome

This book is written by programmers for programmers. All comments and suggestions from the entire computing community are appreciated. We would like to thank the many readers in the past who have helped improve our books with their thoughtful and constructive comments. We can be reached electronically at the following addresses:

Mike Daconta can be reached at [email protected].

Al Saganich can be reached at [email protected].

Best wishes,

Mike Daconta,

Bealeton, Virginia

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.48.62