|2020ok Directory of FREE Online Books and FREE eBooks|
Processing Xml With Java: A Guide To Sax, Dom, Jdom, Jaxp, And Trax
by Elliotte Rusty Harold
(Respecting the intellectual property of others is utmost important to us, we make every effort to make sure we only link to legitimate sites, such as those sites owned by authors and publishers. If you have any questions about these links, please contact us.)
Java is the ideal language for processing XML documents. Consequently, more XML tools have been written in Java than in any other language. More open source XML tools are written in Java than in any other language. Processing XML with Java fills an immediate need for developers who are working with XML in Java. It is a comprehensive tutorial and reference to the major APIs. This book shows developers how to: save XML documents from their applications written in Java; read XML documents produced by other programs; communicate with network servers that send and receive XML data; validate documents they receive against DTDs, schemas, and business rules; and integrate XSLT into their programs.
A complete guide to writing Java programs that read and write XML documents. Shows developers how to save XML documents, read XML documents, communicate with network servers that send and receive XML data, and integrate XSLT into their programs. Softcover.
From the Back Cover
Praise for Elliotte Rusty Haroldâs Processing XML with Javaâ¢
âThe sophistication and language are very appropriate for Java and XML application developers. You can tell by the way the author writes that he too is a developer. He delves very deeply into the topics and has really taken things apart and investigated how they work. I especially like his coverage of âgotchas,â pitfalls, and limitations of the technologies.ââJohn Wegis, Web Engineer, Sun Microsystems, Inc.
âElliotte has written an excellent book on XML that covers a lot of ground and introduces current and emerging technologies. He helps the novice programmer understand the concepts and principles of XML and related technologies, while covering the material at a level thatâs deep enough for the advanced developer. With a broad coverage of XML technologies, lots of little hints, and information I havenât seen in any other book on the topic, this work has become a valuable addition to my technical library.ââRobert W. Husted, Member, Technical Staff, Requisite Technology, Inc.
âThe code examples are well structured and easy to follow. They provide real value for someone writing industrial-strength Java and XML applications. The time saved will repay the cost of this book a hundred times over.
âThe book also contains more of the pearls of wisdom weâve come to expect from Elliotte Rusty Haroldâthe kind of pointers that will save developers weeks, if not months, of time.ââRon Weber, Independent Software Consultant
Written for Java programmers who want to integrate XML into their systems, this practical, comprehensive guide and reference shows how to process XML documents with the Java programming language. It leads experienced Java developers beyond the basics of XML, allowing them to design sophisticated XML applications and parse complicated documents.
Processing XML with Javaâ¢ provides a brief review of XML fundamentals, including XML syntax; DTDs, schemas, and validity; stylesheets; and the XML protocols XML-RPC, SOAP, and RSS. The core of the book comprises in-depth discussions on the key XML APIs Java programmers must use to create and manipulate XML files with Java. These include the Simple API for XML (SAX), the Document Object Model (DOM), and JDOM (a Java native API). In addition, the book covers many useful supplements to these core APIs, including XPath, XSLT, TrAX, and JAXP.
Practical in focus, Processing XML with Javaâ¢is filled with over two hundred examples that demonstrate how to accomplish various important tasks related to file formats, data exchange, document transformation, and database integration. You will learn how to read and write XML documents with Java code, convert legacy flat files into XML documents, communicate with network servers that send and receive XML data, and much more. Readers will find detailed coverage of the following:
In addition, the book includes a convenient quick reference that summarizes the major elements of all the XML APIs discussed. A related Web site, located at http://www.cafeconleche.org/books/xmljava/, contains the entire book in electronic format, as well as updates and links referenced in the book.
With thorough coverage of the key XML APIs and a practical, task-oriented approach, Processing XML with Javaâ¢ is a valuable resource for all Java programmers who need to work with XML.
About the Author
Elliotte Rusty Harold is an internationally respected writer, programmer, and educator. He is an Adjunct Professor of Computer Science at Polytechnic University in Brooklyn, where he lectures on Java and object-oriented programming. His Cafe con Leche Web site has become one of the most popular sites for information on XML. In addition, he is the author and coauthor of numerous books, the most recent of which are The XML Bible (John Wiley & Sons, 2001) and XML in a Nutshell (O'Reilly, 2002).
Excerpt. © Reprinted by permission. All rights reserved.
One night five developers, all of whom wore very thick glasses and had recently been hired by Elephants, Inc., the world's largest purveyor of elephants and elephant supplies, were familiarizing themselves with the company's order processing system when they stumbled into a directory full of XML documents on the main server. "What's this?" the team leader asked excitedly. None of them had ever heard of XML before, so they decided to split up the files among them and try to figure out just what this strange and wondrous new technology was. The first developer, who specialized in optimizing Oracle databases, printed out a stack of FMPXMLRESULT documents generated by the FileMaker Pro database where all the orders were stored, and began poring over them. "So this is XML! Why, it's nothing novel. As anyone can see who's able, an XML document is nothing but a table!"
"What do you mean, a table?" replied the second developer, well versed in object-oriented theory and occupied with a collection of XMI documents that encoded UML diagrams for the system. "Even a Visual Basic programmer could see that XML documents aren't tables. Duplicates aren't allowed in a table relation, unless this is truly some strange mutation. Classes and objects are what these documents are. Indeed, it should be obvious on the very first pass. An XML document is an object, and a DTD is a class."
"Objects? A strange kind of object, indeed!" said the third developer, a web designer of some renown, who had loaded the XHTML user documentation for the order processing system into Mozilla."I don't see any types at all. If you think this is an object, then it's your software I refuse to install. But with all those stylesheets there, it should be clear to anyone not sedated that XML is just HTML updated!"
"HTML? You must be joking" said the fourth, a computer science professor on sabbatical from MIT, who was engrossed in an XSLT stylesheet that validated all of the other documents against a Schematron schema. "Look at the clean nesting of hierarchical structures, each tag matching its partner as it should. I've never seen HTML that looks this good. What we have here is S-expressions, which is certainly nothing new. Babbage invented this back in 1882!"
"S-expressions?" queried the technical writer, who was occupied with documentation for the project, written in DocBook. "Maybe that means something to those in your learned profession. But to me, this looks just like a FrameMaker MIF file. However, locating the GUI does seem to be taking me a while."
And so they argued into the night, none of them willing to give an inch, all of them presenting still more examples to prove their points, but none bothering to look at the others' examples. Indeed, they're probably still arguing today. You can even hear their shouts from time to time on xml-dev. Their mistake, of course, was in trying to force XML into the patterns of technologies they were already familiar with rather than taking it on its own terms. XML can store data, but it is not a database. XML can serialize objects, but an XML document is not an object. Web pages can be written in XML, but XML is not HTML. Functional (and other) programming languages can be written in XML, but XML is not a programming language. Books are written in XML, but that doesn't make XML desktop publishing software.XML is something truly new that has not been seen before in the world of computing. There have been precursors to it, and there are always fanatics who insist on seeing XML through database (or object, or functional, or S-expression) colored glasses. But XML is none of these things. It is something genuinely unique and new in the world of computing; and it's possible to understand it only when you're willing to accept it on its own terms, rather than forcing it into yesterday's pigeonholes.
There are a lot of tools, APIs, and applications in the world that pretend XML is something more familiar to developers--that it's just a funny kind of database, or just like an object, or just like remote procedure calls. These APIs are occasionally useful in very restricted and predictable environments; however, they are not suitable for processing XML in its most general format. They work well in their limited domains, but they fail when presented with XML that steps outside the artificial boundaries they've defined. XML was designed to be extensible, but sadly many of the tools designed for XML aren't nearly as extensible as XML itself.
This book is going to show you how to handle XML in its full generality. It pulls no punches. It does not pretend that XML is anything except XML, and it shows you how to design your programs so that they handle real XML in all its messiness: valid and invalid, mixed and unmixed, typed and untyped, and both all and none of these at the same time. To that end, this book focuses on APIs that don't try to hide the XML. In particular, there are three major Java APIs that correctly model XML, as opposed to modeling a particular class of XML documents or some narrow subset of XML. These are
These APIs are the core of this book. In addition, I cover a number of preliminaries and supplements to the basic APIs, including
And, since we're going to need a few examples of XML applications to demonstrate the APIs, I also cover XML-RPC, SOAP, and RSS in some detail. However, the techniques this book teaches are hardly limited to those three applications.
Who You Are
This book is written for experienced Java developers who want to integrate XML into their systems. Java is the ideal language for processing XML documents. Its strong Unicode support in particular made it the preferred language for many early implementers. Consequently, more XML tools have been written in Java than in any other language. More open source XML tools are written in Java than in any other language. More developers process XML in Java than in any other language.
Processing XML with Java will teach you how to
This book is intended for Java developers who need to do anything with XML. It teaches the fundamentals and advanced topics, leaving nothing out. It is a comprehensive course in processing XML with Java that takes developers from having little knowledge of XML to designing sophisticated XML applications and parsing complicated documents. The examples cover a wide range of possible uses, including file formats, data exchange, document transformation, database integration, and more.
What You Need to Know
This is not an introductory book with respect to either Java or XML. I assume you have substantial prior experience with Java and preferably some experience with XML. On the Java side, I freely use advanced features of the language and its class library without explanation or apology. Among other things, I assume you are thoroughly familiar with the following:
In addition, in one or two places in this book I use some SQL and JDBC. These sections are relatively independent of the rest of the book, however, and chances are if you aren't already familiar with SQL, then you don't need the material in these sections anyway.
What You Need to Have
XML is deliberately architecture, platform, operating system, GUI, and language agnostic (in fact, more so than Java). It works equally well on Mac OS, Windows, Linux, OS/2, various flavors of Unix, and more. It can be processed with Python, C++, Haskell, ECMAScript, C#, Perl, Visual Basic, Ruby, and of course Java. No byte-order issues need concern you if you switch between PowerPC, X86, or other architectures. Almost everything in this book should work equally well on any platform that's capable of running Java.
Most of the material in this book is relatively independent of the specific Java version. Java 1.4 bundles SAX, DOM, and a few other useful classes into the core JDK. However, these are easily installed in earlier JVMs as open source libraries from the Apache XML Project and other vendors. For the most part, I used Java 1.3 and 1.4 when testing the examples; therefore, it's possible that a few of the classes and methods used are not available in earlier versions. In most cases, it should be fairly obvious how to backport them. All of the basic XML APIs except TrAX should work in Java 1.1 and later. TrAX requires Java 1.2 or later.
How to Use This Book
This book is organized as an advanced tutorial that can also serve as a solid and comprehensive reference. Chapter 1 covers the bare minimum material needed to start working with XML, although for the most part this is not intended as a comprehensive introduction, but more as a review for readers who already have read other, more basic books. Chapter 2 introduces RSS, XML-RPC, and SOAP, the XML applications used for examples throughout the rest of the book. This is followed by two chapters on generating XML f...
Related Free eBooks