Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX

Book description

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 el

    Table of contents

    1. Copyright
    2. Praise for Elliotte Rusty Harold's Processing XML with Java™
    3. List of Examples
    4. List of Figures
    5. Preface
    6. XML
      1. XML for Data
        1. Motivating XML
        2. XML Syntax
        3. Validity
        4. Stylesheets
        5. Summary
      2. XML Protocols: XML-RPC and SOAP
        1. XML as a Message Format
        2. HTTP as a Transport Protocol
        3. RSS
        4. Customizing the Request
        5. XML-RPC
        6. SOAP
        7. Custom Protocols
        8. Summary
      3. Writing XML with Java
        1. Fibonacci Numbers
        2. Writing XML
        3. Output Streams, Writers, and Encodings
        4. A Simple XML-RPC Client
        5. A Simple SOAP Client
        6. Servlets
        7. Summary
      4. Converting Flat Files to XML
        1. The Budget
        2. The Model
        3. Input
        4. Determining the Output Format
        5. Building Hierarchical Structures from Flat Data
        6. Alternatives to Java
        7. Relational Databases
        8. Summary
      5. Reading XML
        1. InputStreams and Readers
        2. XML Parsers
        3. SAX
        4. DOM
        5. JAXP
        6. JDOM
        7. dom4j
        8. ElectricXML
        9. XMLPULL
        10. Summary
    7. SAX
      1. SAX
        1. What Is SAX?
        2. Parsing
        3. Callback Interfaces
        4. Receiving Documents
        5. Receiving Elements
        6. Handling Attributes
        7. Receiving Characters
        8. Receiving Processing Instructions
        9. Receiving Namespace Mappings
        10. “Ignorable White Space”
        11. Receiving Skipped Entities
        12. Receiving Locators
        13. What the ContentHandler Doesn't Tell You
        14. Summary
      2. The XMLReader Interface
        1. Building Parser Objects
        2. Input
        3. Exceptions and Errors
        4. Features and Properties
        5. DTDHandler
        6. Summary
      3. SAX Filters
        1. The Filter Architecture
        2. The XMLFilter Interface
        3. Content Filters
        4. The XMLFilterImpl Class
        5. Parsing Non-XML Documents
        6. Multihandler Adapters
        7. Summary
    8. DOM
      1. The Document Object Model
        1. The Evolution of DOM
        2. DOM Modules
        3. Application-Specific DOMs
        4. Trees
        5. DOM Parsers for Java
        6. Parsing Documents with a DOM Parser
        7. The Node Interface
        8. The NodeList Interface
        9. JAXP Serialization
        10. DOMException
        11. Choosing between SAX and DOM
        12. Summary
      2. Creating XML Documents with DOM
        1. DOMImplementation
        2. Locating a DOMImplementation
        3. The Document Interface as an Abstract Factory
        4. The Document Interface as a Node Type
        5. Normalization
        6. Summary
      3. The DOM Core
        1. The Element Interface
        2. The NamedNodeMap Interface
        3. The CharacterData Interface
        4. The Text Interface
        5. The CDATASection Interface
        6. The EntityReference Interface
        7. The Attr Interface
        8. The ProcessingInstruction Interface
        9. The Comment Interface
        10. The DocumentType Interface
        11. The Entity Interface
        12. The Notation Interface
        13. Summary
      4. The DOM Traversal Module
        1. NodeIterator
        2. NodeFilter
        3. TreeWalker
        4. Summary
      5. Output from DOM
        1. Xerces Serialization
        2. OutputFormat
        3. DOM Level 3
        4. Summary
    9. JDOM
      1. JDOM
        1. What Is JDOM?
        2. Creating XML Elements with JDOM
        3. Creating XML Documents with JDOM
        4. Writing XML Documents with JDOM
        5. Document Type Declarations
        6. Namespaces
        7. Reading XML Documents with JDOM
        8. Navigating JDOM Trees
        9. Talking to DOM Programs
        10. Talking to SAX Programs
        11. Java Integration
        12. What JDOM Doesn't Do
        13. Summary
      2. The JDOM Model
        1. The Document Class
        2. The Element Class
        3. The Attribute Class
        4. The Text Class
        5. The CDATA Class
        6. The ProcessingInstruction Class
        7. The Comment Class
        8. Namespaces
        9. The DocType Class
        10. The EntityRef Class
        11. Summary
    10. XPath/XSLT
      1. XPath
        1. Queries
        2. The XPath Data Model
        3. Location Paths
        4. Expressions
        5. XPath Engines
        6. DOM Level 3 XPath
        7. Jaxen
        8. Summary
      2. XSLT
        1. XSL Transformations
        2. TrAX
        3. Extending XSLT with Java
        4. Summary
    11. Appendixes
      1. XML API Quick Reference
        1. SAX
        2. DOM
        3. JAXP
        4. TrAX
        5. JDOM
        6. XMLPULL
      2. SOAP 1.1 Schemas
        1. The SOAP 1.1 Envelope Schema
        2. The SOAP 1.1 Encoding Schema
        3. W3C Software Notice and License
      3. Recommended Reading
        1. Books
        2. Specifications

    Product information

    • Title: Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX
    • Author(s): Elliotte Rusty Harold
    • Release date: November 2002
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 0201771861