Java and XML, Second Edition

Book description

While the XML "buzz" still dominates talk among Internet developers, the critical need is for information that cuts through the hype and lets Java programmers put XML to work. Java & XML shows how to use the APIs, tools, and tricks of XML to build real-world applications, with the end result that both the data and the code are portable. This second edition of Java & XML adds chapters on Advanced SAX and Advanced DOM, new chapters on SOAP and data binding, and new examples throughout. A concise chapter on XML basics introduces concepts, and the rest of the book focuses on using XML from your Java applications. Java developers who need to work with XML, or think that they will in the future--as well as developers involved in the new peer-to-peer movement, messaging, or web services--will find the new Java & XML a constant companion. This book covers:

  • The basics of XML, including DTDs, namespaces, XML Schema, XPath, and XSL

  • The SAX API, including all handlers, the SAX 2 extensions, filters, and writers

  • The DOM API, including DOM Level 2, Level 3, and the Traversal, Range, CSS, Events, and HTML modules.

  • The JDOM API, including the core, a look at XPath support, and JDOM as a JSR

  • Using web publishing frameworks like Apache Cocoon

  • Developing applications with XML-RPC

  • Using SOAP and UDDI for web services

  • Data Binding, using both DTDs and XML Schema for constraints

  • Building business-to-business applications with XML

  • Building information channels with RSS and dynamic content with XSP

Includes a quick reference on SAX 2.0, DOM Level 2, and JDOM.

Table of contents

  1. Java and XML, 2nd Edition
    1. Preface
      1. Organization
      2. Who Should Read This Book?
      3. Software and Versions
      4. Conventions Used in This Book
      5. Comments and Questions
      6. Acknowledgments
    2. 1. Introduction
      1. XML Matters
        1. Portability
        2. Interoperability
        3. It Doesn’t Matter
      2. What’s Important?
        1. Low-Level APIs
        2. High-Level APIs
        3. XML-Based Applications
      3. The Essentials
        1. An Operating System and Java
        2. A Parser
        3. APIs
        4. Application Software
      4. What’s Next?
    3. 2. Nuts and Bolts
      1. The Basics
        1. XML 1.0
          1. The root element
          2. Elements
          3. Attributes
          4. Entity references and constants
          5. Unparsed data
        2. Namespaces
      2. Constraints
        1. DTDs
          1. Elements
          2. Attributes
          3. Entities
        2. XML Schema
          1. Elements and attributes
          2. Multiple namespaces
      3. Transformations
        1. XSL
          1. XSL and trees
          2. Formatting objects
        2. XSLT
        3. XPath
          1. Template matching
          2. Looping
          3. Copying
      4. And More...
      5. What’s Next?
    4. 3. SAX
      1. Getting Prepared
        1. Obtaining a Parser
        2. Getting the SAX Classes and Interfaces
        3. Have an XML Document on Hand
      2. SAX Readers
        1. Instantiating a Reader
        2. Parsing the Document
        3. Using an InputSource
      3. Content Handlers
        1. The Document Locator
        2. The Beginning and the End of a Document
        3. Processing Instructions
        4. Namespace Callbacks
        5. Element Callbacks
        6. Element Data
        7. Ignorable Whitespace
        8. Entities
        9. The Results
      4. Error Handlers
        1. Warnings
        2. Nonfatal Errors
        3. Fatal Errors
        4. Breaking the Data
      5. Gotcha!
        1. My Parser Doesn’t Support SAX 2.0
        2. The SAX XMLReader: Reused and Reentrant
        3. The Misplaced Locator
        4. Getting Ahead of the Data
      6. What’s Next?
    5. 4. Advanced SAX
      1. Properties and Features
        1. Setting Properties and Features
        2. SAX Properties and Features
          1. Validation
          2. Namespaces
          3. Interning and entities
          4. DOM nodes and literal strings
        3. Proprietary Properties and Features
      2. More Handlers
        1. Using an EntityResolver
        2. Using a DTDHandler
        3. The DefaultHandler Class
      3. Filters and Writers
        1. XMLFilters
        2. XMLWriter
      4. Even More Handlers
        1. LexicalHandler
        2. DeclHandler
      5. Gotcha!
        1. Return Values from an EntityResolver
        2. DTDHandler and Validation
        3. Parsing on the Reader Instead of the Filter
      6. What’s Next?
    6. 5. DOM
      1. The Document Object Model
        1. Language Bindings
        2. The Basics
        3. Why Not SAX?
          1. SAX is sequential
          2. SAX siblings
          3. Why use SAX at all?
      2. Serialization
        1. Getting a DOM Parser
        2. DOM Parser Output
        3. DOMSerializer
          1. Getting started
          2. Launching serialization
          3. Working with nodes
        4. The Results
      3. Mutability
      4. Gotcha!
        1. Memory, Performance, and Deferred DOMs
        2. Polymorphism and the Node Interface
        3. DOM Parsers Throwing SAX Exceptions
      5. What’s Next?
    7. 6. Advanced DOM
      1. Changes
        1. Creating a New DOM Tree
        2. Modifying a DOM Tree
      2. Namespaces
      3. DOM Level 2 Modules
        1. Branching Out
        2. Traversal
          1. NodeIterator
          2. TreeWalker
        3. Range
        4. Events, Views, and Style
          1. Events
          2. Views
          3. Style
        5. HTML
        6. Odds and Ends
      4. DOM Level 3
        1. The XML Declaration
        2. Node Comparisons
        3. Bootstrapping
      5. Gotcha!
        1. The Dreaded WRONG DOCUMENT Exception
        2. Creating, Appending, and Inserting
      6. What’s Next?
    8. 7. JDOM
      1. The Basics
        1. Java Collections Support
        2. Concrete Classes and Factories
        3. Input and Output
      2. PropsToXML
        1. Java Properties Files
        2. Converting to XML
        3. Creating XML with JDOM
        4. Outputting XML with JDOM
      3. XMLProperties
        1. Storing XML
        2. Loading XML
        3. Taking a Test Drive
        4. Backtracking
      4. Is JDOM a Standard?
        1. JDOM as a JSR
        2. SAX and DOM as Standards
      5. Gotcha!
        1. JDOM isn’t DOM
        2. Null Return Values
        3. DOMBuilder
      6. What’s Next?
    9. 8. Advanced JDOM
      1. Helpful JDOM Internals
        1. The Text Class
        2. The EntityRef Class
        3. The Namespace Class
      2. JDOM and Factories
        1. Creating a Factory
        2. Building with Custom Classes
      3. Wrappers and Decorators
        1. JDOMNode
        2. Implementing Classes
        3. Providing Support for XPath
        4. Endgame
      4. Gotcha!
        1. More on Subclassing
        2. Creating Invalid XML
      5. What’s Next?
    10. 9. JAXP
      1. API or Abstraction
        1. Sun’s JAXP and Parser
        2. The Old and the New
      2. JAXP 1.0
        1. Starting with SAX
          1. A look at the SAXParserFactory class
          2. Working with the SAXParser class
        2. Dealing with DOM
          1. A look at the DOM parser factory
          2. Working with the DOM parser
        3. Changing the Parser
      3. JAXP 1.1
        1. Updating the Standards
          1. The road to SAX 2.0
          2. Changes in SAX classes
          3. Updates to the DOM
        2. The TrAX API
          1. Working with the factory
          2. Transforming XML
          3. Odds and ends
      4. Gotcha!
        1. Default Parsers and JAXP Implementations
        2. Features on Factories, Properties on Parsers
      5. What’s Next?
    11. 10. Web Publishing Frameworks
      1. Selecting a Framework
        1. Stability
        2. Integration with Other XML Tools and APIs
        3. Production Presence
        4. Making the Decision
      2. Installation
        1. Source Code or Binaries
        2. Configuring the Servlet Engine
      3. Using a Publishing Framework
        1. Viewing XML Converted to HTML
        2. Viewing PDFs from XML
        3. Browser-Dependent Styling
        4. WAP and XML
      4. XSP
        1. Creating an XSP Page
        2. Using XSP Tag Libraries
      5. Cocoon 2.0 and Beyond
        1. Servlet Engine Mappings
        2. The Sitemap
        3. Producers and Processors
      6. What’s Next?
    12. 11. XML-RPC
      1. RPC Versus RMI
        1. What Is RMI?
        2. What Is RPC?
        3. XML-RPC
      2. Saying Hello
        1. XML-RPC Libraries
        2. Writing the Handler
        3. Writing the Server
        4. Writing the Client
        5. Talk to Me
      3. Putting the Load on the Server
        1. A Shared Handler
        2. A Configurable Server
        3. A Useful Client
        4. Talk to Me (Again)
      4. The Real World
        1. Where’s the XML in XML-RPC?
        2. Shared Instances
        3. To Servlet or Not To Servlet
      5. What’s Next?
    13. 12. SOAP
      1. Starting Out
        1. The Envelope
        2. Encoding
        3. Invocation
      2. Setting Up
        1. Other Options
          1. What about IBM SOAP4J?
          2. Isn’t Microsoft a player?
          3. What’s Axis?
        2. Installation
          1. The client
          2. The server
          3. The router servlet and admin client
      3. Getting Dirty
        1. RPC or Messaging?
        2. An RPC Service
          1. Code artifacts
          2. Deployment descriptors
          3. Deploying the service
        3. An RPC Client
      4. Going Further
        1. Custom Parameter Types
        2. Better Error Handling
      5. What’s Next?
    14. 13. Web Services
      1. Web Services
      2. UDDI
      3. WSDL
      4. Putting It All Together
        1. A Messaging Service
        2. Registering with UDDI
        3. Searching a UDDI Registry
        4. WSDL
        5. Writing a Client
        6. Where Do I Go From Here?
      5. What’s Next?
    15. 14. Content Syndication
      1. The Foobar Public Library
        1. Evaluating the Requirements
        2. Entering the Books
        3. Providing a Listing of Available Books
      2. mytechbooks.com
        1. Filtering XML Data
        2. XSLT from a Servlet
      3. Push Versus Pull
        1. Rich Site Summary
        2. Creating an XML RSS Document
        3. Taking a Test Drive
        4. What Happened to Netcenter?
      4. What’s Next?
    16. 15. Data Binding
      1. First Principles
        1. Class Generation
        2. Unmarshalling
        3. Marshalling
        4. Use Cases
      2. Castor
        1. Installation
        2. Source Generation
        3. Marshalling and Unmarshalling
      3. Zeus
        1. Installation
        2. Class Generation
        3. Marshalling and Unmarshalling
      4. JAXB
        1. Installation
        2. Class Generation
        3. Marshalling and Unmarshalling
      5. What’s Next?
    17. 16. Looking Forward
      1. XLink
      2. XPointer
      3. XML Schema Bindings
      4. And the Rest. . .
      5. What’s Next?
    18. A. API Reference
      1. SAX 2.0
        1. Package: org.xml.sax
          1. AttributeList [deprecated]
          2. Attributes
          3. ContentHandler
          4. DocumentHandler
          5. DTDHandler
          6. EntityResolver
          7. ErrorHandler
          8. HandlerBase
          9. InputSource
          10. Locator
          11. Parser
          12. SAXException
          13. SAXNotRecognizedException
          14. SAXNotSupportedException
          15. SAXParseException
          16. XMLFilter
          17. XMLReader
        2. Package: org.xml.sax.ext
          1. DeclHandler
          2. LexicalHandler
        3. Package: org.xml.sax.helpers
          1. AttributeListImpl
          2. AttributesImpl
          3. DefaultHandler
          4. LocatorImpl
          5. NamespaceSupport
          6. ParserAdapter
          7. ParserFactory
          8. XMLFilterImpl
          9. XMLReaderAdapter
          10. XMLReaderFactory
      2. DOM Level 2
        1. Package: org.w3c.dom
          1. Attr
          2. CDATASection
          3. CharacterData
          4. Comment
          5. Document
          6. DocumentFragment
          7. DocumentType
          8. DOMException
          9. DOMImplementation
          10. Element
          11. Entity
          12. EntityReference
          13. NamedNodeMap
          14. Node
          15. NodeList
          16. Notation
          17. ProcessingInstruction
          18. Text
      3. JAXP 1.1
        1. Package: javax.xml.parsers
          1. DocumentBuilder
          2. DocumentBuilderFactory
          3. FactoryConfigurationError
          4. ParserConfigurationException
          5. SAXParser
          6. SAXParserFactory
        2. Package: javax.xml.transform
          1. ErrorListener
          2. OutputKeys
          3. Result
          4. Source
          5. SourceLocator
          6. Templates
          7. Transformer
          8. TransformerFactory
          9. URIResolver
        3. Package: javax.xml.transform.dom
        4. Package: javax.xml.transform.sax
        5. Package: javax.xml.transform.stream
      4. JDOM 1.0 (Beta 7)
        1. Package: org.jdom
          1. Attribute
          2. CDATA
          3. Comment
          4. DocType
          5. Document
          6. Element
          7. EntityRef
          8. JDOMException
          9. Namespace
          10. ProcessingInstruction
          11. Text
        2. Package: org.jdom.adapters
          1. AbstractDOMAdapter
          2. DOMAdapter
        3. Package: org.jdom.input
          1. BuilderErrorHandler
          2. DOMBuilder
          3. JDOMFactory
          4. SAXBuilder
        4. Package: org.jdom.output
    19. B. SAX 2.0 Features and Properties
      1. Core Features
        1. Namespace Processing
        2. Namespace Prefix Reporting
        3. String Interning
        4. Validation
        5. Process External Entities (General)
        6. Process External Entities (Parameter)
      2. Core Properties
        1. Lexical Handler
        2. Declaration Handler
        3. DOM Node
        4. Literal (XML) String
    20. Index
    21. Colophon

Product information

  • Title: Java and XML, Second Edition
  • Author(s): Brett McLaughlin
  • Release date: August 2001
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596001971