OReilly - Processing XML with Java.pdf

(3525 KB) Pobierz
1
Processing XML with Java
Elliotte Rusty Harold
Copyright © 2001, 2002 Elliotte Rusty Harold
Dedication
In memory of all the victims of the attacks on the World Trade Center and the Pentagon,
September 11, 2001
Table of Contents
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
Acknowledgements
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
2
The Last Mile
Style sheets
CSS
Associating Style Sheets with XML Documents
XSL
Summary
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 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
Summary
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
Summary
4.
Converting Flat Files to XML
The Budget
The Model
3
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
Summary
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
Summary
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
Summary
7.
The XMLReader Interface
Building Parser Objects
Input
InputSource
4
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
Summary
8.
SAX Filters
The Filter Architecture
The XMLFilter interface
Content Filters
Filtering Tags
Filtering Elements
Filtering attributes
Filters that add content
Filters vs. Transforms
The XMLFilterImpl Class
Parsing non-XML Documents
Multihandler adapters
Summary
9.
The Document Object Model
The Evolution of DOM
DOM Modules
Application Specific DOMs
Trees
Document nodes
Element nodes
Attribute nodes
Leaf nodes
Non-tree 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
5
Modifying the tree
Utility Methods
The NodeList interface
JAXP Serialization
DOMException
Choosing between SAX and DOM
Summary
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
Summary
11.
The Document Object Model 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
Summary
12.
The DOM Traversal Module
NodeIterator
Constructing NodeIterators with DocumentTraversal
Liveness
Filtering by Node Type
NodeFilter
TreeWalker
Summary
13.
Output from DOM
Xerces Serialization
Zgłoś jeśli naruszono regulamin