×

Uh-oh, it looks like your Internet Explorer is out of date.

For a better shopping experience, please upgrade now.

Processing XML with Java': A Guide to SAX, DOM, JDOM, JAXP, and TrAX / Edition 1
     

Processing XML with Java': A Guide to SAX, DOM, JDOM, JAXP, and TrAX / Edition 1

5.0 1
by Elliotte Rusty Harold
 

See All Formats & Editions

ISBN-10: 0201771861

ISBN-13: 9780201771862

Pub. Date: 11/19/2002

Publisher: Addison-Wesley

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.

Overview

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:

  • How to choose the right API for the job
  • Reading documents with SAX
  • SAX filters
  • Validation in several schema languages
  • DOM implementations for Java
  • The DOM Traversal Module
  • Output from DOM
  • Reading and writing XML documents with JDOM
  • Searching XML documents with XPath
  • Combining XSLT transforms with Java code
  • TrAX, the Transformations API for XML
  • JAXP, the Java API for XML Processing

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.

Product Details

ISBN-13:
9780201771862
Publisher:
Addison-Wesley
Publication date:
11/19/2002
Pages:
1120
Product dimensions:
7.40(w) x 9.10(h) x 2.30(d)

Table of Contents

(NOTE: Each chapter concludes with a Summary.)

List of Examples.

List of Figures.

Preface.

Who You Are.

What You Need to Know.

What You Need to Have.

How to Use This Book.

The Online Edition.

Some Grammatical Notes.

Contacting the Author.

Acknowledgments.

I. XML.

1. XML for Data.

Motivating XML.

A Thought Experiment.

Robustness.

Extensibility.

Ease-of-Use.

XML Syntax.

XML Documents.

XML Applications.

Elements and Tags.

Text.

Attributes.

XML Declaration.

Comments.

Processing Instructions.

Entities.

Namespaces.

Validity.

DTDs.

Schemas.

Schematron.

The Last Mile.

Stylesheets.

CSS.

Associating Stylesheets with XML Documents.

XSL.

2. XML Protocols: XML-RPC and SOAP.

XML as a Message Format.

Envelopes.

Data Representation.

HTTP as a Transport Protocol.

How HTTP Works.

HTTP in Java.

RSS.

Customizing the Request.

Query Strings.

How HTTP POST Works.

XML-RPC.

Data Structures.

Faults.

Validating XML-RPC.

SOAP.

A SOAP Example.

Posting SOAP Documents.

Faults.

Encoding Styles.

SOAP Headers.

SOAP Limitations.

Validating SOAP.

Custom Protocols.

3. Writing XML with Java.

Fibonacci Numbers.

Writing XML.

Better Coding Practices.

Attributes.

Producing Valid XML.

Namespaces.

Output Streams, Writers, and Encodings.

A Simple XML-RPC Client.

A Simple SOAP Client.

Servlets.

4. Converting Flat Files to XML.

The Budget.

The Model.

Input.

Determining the Output Format.

Validation.

Attributes.

Building Hierarchical Structures from Flat Data.

Alternatives to Java.

Imposing Hierarchy with XSLT.

The XML Query Language.

Relational Databases.

5. Reading XML.

InputStreams and Readers.

XML Parsers.

Choosing an XML API.

Choosing an XML Parser.

Available Parsers.

SAX.

DOM.

JAXP.

JDOM.

dom4j.

ElectricXML.

XMLPULL.

II. SAX.

6. SAX.

What Is SAX?

Parsing.

Callback Interfaces.

Implementing ContentHandler.

Using the ContentHandler.

The DefaultHandler Adapter Class.

Receiving Documents.

Receiving Elements.

Handling Attributes.

Receiving Characters.

Receiving Processing Instructions.

Receiving Namespace Mappings.

“Ignorable White Space”.

Receiving Skipped Entities.

Receiving Locators.

What the ContentHandler Doesn't Tell You.

7. The XMLReader Interface.

Building Parser Objects.

Input.

InputSource.

EntityResolver.

Exceptions and Errors.

SAXExceptions.

The ErrorHandler Interface.

Features and Properties.

Getting and Setting Features.

Getting and Setting Properties.

Required Features.

Standard Features.

Standard Properties.

Xerces Custom Features.

Xerces Custom Properties.

DTDHandler.

8. SAX Filters.

The Filter Architecture.

The XMLFilter Interface.

Content Filters.

Filtering Tags.

Filtering Elements.

Filtering Attributes.

Filters That Add Content.

Filters versus Transforms.

The XMLFilterImpl Class.

Parsing Non-XML Documents.

Multihandler Adapters.

III. DOM.

The Document Object Model.

The Evolution of DOM.

DOM Modules.

Application-Specific DOMs.

Trees.

Document Nodes.

Element Nodes.

Attribute Nodes.

Leaf Nodes.

Nontree Nodes.

What Is and Isn't in the Tree.

DOM Parsers for Java.

Parsing Documents with a DOM Parser.

JAXP DocumentBuilder and DocumentBuilderFactory.

DOM3 Load and Save.

The Node Interface.

Node Types.

Node Properties.

Navigating the Tree.

Modifying the Tree.

Utility Methods.

The NodeList Interface.

JAXP Serialization.

DOMException.

Choosing between SAX and DOM.

10. Creating XML Documents with DOM.

DOMImplementation.

Locating a DOMImplementation.

Implementation-Specific Class.

JAXP DocumentBuilder.

DOM3 DOMImplementationRegistry.

The Document Interface as an Abstract Factory.

The Document Interface as a Node Type.

Getter Methods.

Finding Elements.

Transferring Nodes between Documents.

Normalization.

11 The DOM Core.

The Element Interface.

Extracting Elements.

Attributes.

The NamedNodeMap Interface.

The CharacterData Interface.

The Text Interface.

The CDATASection Interface.

The EntityReference Interface.

The Attr Interface.

The ProcessingInstruction Interface.

The Comment Interface.

The DocumentType Interface.

The Entity Interface.

The Notation Interface.

12. The DOM Traversal Module.

NodeIterator.

Constructing NodeIterators with DocumentTraversal.

Liveness.

Filtering by Node Type.

NodeFilter.

TreeWalker.

13. Output from DOM.

Xerces Serialization.

OutputFormat.

DOM Level 3.

Creating DOMWriters.

Serialization Features.

Filtering Output.

IV. JDOM.

14. JDOM.

What Is JDOM?

Creating XML Elements with JDOM.

Creating XML Documents with JDOM.

Writing XML Documents with JDOM.

Document Type Declarations.

Namespaces.

Reading XML Documents with JDOM.

Navigating JDOM Trees.

Talking to DOM Programs.

Talking to SAX Programs.

Configuring SAXBuilder.

SAXOutputter.

Java Integration.

Serializing JDOM Objects.

Synchronizing JDOM Objects.

Testing Equality.

Hash Codes.

String Representations.

Cloning.

What JDOM Doesn't Do.

15. The JDOM Model.

The Document Class.

The Element Class.

Constructors.

Navigation and Search.

Attributes.

The Attribute Class.

The Text Class.

The CDATA Class.

The ProcessingInstruction Class.

The Comment Class.

Namespaces.

The DocType Class.

The EntityRef Class.

V. XPath/XSLT.

16. XPath.

Queries.

The XPath Data Model.

Location Paths.

Axes.

Node Tests.

Predicates.

Compound Location Paths.

Absolute Location Paths.

Abbreviated Location Paths.

Combining Location Paths.

Expressions.

Literals.

Operators.

Functions.

XPath Engines.

XPath with Saxon.

XPath with Xalan.

DOM Level 3 XPath.

Namespace Bindings.

Snapshots.

Compiled Expressions.

Jaxen.

17. XSLT.

XSL Transformations.

Template Rules.

Stylesheets.

Taking the Value of a Node.

Applying Templates.

The Default Template Rules.

Selection.

Calling Templates by Name.

TrAX.

Thread Safety.

Locating Transformers.

The xml-stylesheet Processing Instruction.

Features.

XSLT Processor Attributes.

URI Resolution.

Error Handling.

Passing Parameters to Stylesheets.

Output Properties.

Sources and Results.

Extending XSLT with Java.

Extension Functions.

Extension Elements.

VI. APPENDIXES.

Appendix A: XML API Quick Reference.

SAX.

org.xml.sax.

org.xml.sax.ext.

org.xml.sax.helpers.

DOM.

The DOM Data Model.

org.w3c.dom.

org.w3c.dom.traversal.

JAXP.

javax.xml.parsers.

TrAX.

javax.xml.transform.

javax.xml.transform.stream.

javax.xml.transform.dom.

javax.xml.transform.sax.

JDOM.

org.jdom.

org.jdom.filter.

org.jdom.input.

org.jdom.output.

org.jdom.transform.

org.jdom.xpath.

XMLPULL.

org.xmlpull.v1.

Appendix B: SOAP 1.1 Schemas.

The SOAP 1.1 Envelope Schema.

The SOAP 1.1 Encoding Schema.

W3C Software Notice and License.

Appendix C: Recommended Reading.

Books.

Specifications.

Index. 0201771861T10222002

Customer Reviews

Average Review:

Post to your social network

     

Most Helpful Customer Reviews

See all customer reviews

Processing XML with Java': A Guide to SAX, DOM, JDOM, JAXP, and TrAX 5 out of 5 based on 0 ratings. 1 reviews.
Guest More than 1 year ago
It used to be that to get a job as a java programmer, all you typically needed was knowledge of java itself plus some general background in computer science. But today we have a severe high tech slump, and technology has also moved on. The former has caused companies that are still hiring, and those that are picking programmers to retain, to require a broader skill set. One of these has been produced by the latter, XML. It really is shaping up that data serialisation is increasingly in XML format, if that data exists outside a database. So for professional reasons you should learn XML, if you are indeed any type of programmer. For example, Microsoft's .NET revolves around XML, and they don't use java. But it turns out that the coupling between java and XML is tight. The most advanced parsers for XML exist for java. In C++ and C#, the parsers are essentially one step/generation behind. Given this, where do you turn to learn XML? An excellent choice is this book. A voluminous and eloquent exposition of the uses of XML. Harold covers the latest versions of the SAX and DOM parsers, explaining the relative merits. As a java programmer, you should find the idea behind SAX simple. It uses a callback, similar to that in GUIs. Simpler, in fact, because you can only have a single callback. SAX's biggest drawback is that it does not build a tree of the document. DOM addresses this. Harold explains the tradeoffs, and how you can decide which to use. Plus, he describes JDOM, which is DOM-like, but written expressly for java. You should find JDOM far more intuitive than DOM. There is one place where I must differ with the author. He claims that this book is for the experienced java programmer who has already had some XML. I think he is being too conservative; he doesn't want to oversell this book to someone who will not benefit from it. I claim that if you are experienced, by which I mean you have a year or more in java, then you have the intellectual wherewithal to gain, even if you have never seen a stitch of XML.