Home Page Icon
Home Page
Table of Contents for
Java and XML
Close
Java and XML
by Brett McLaughlin
Java and XML
Java and XML
Preface
Organization
Who Should Read This Book?
Software and Versions
Conventions Used in This Book
Comments and Questions
Acknowledgments
1. Introduction
What Is It?
XML
PI
DTD
Namespaces
XSL and XSLT
XPath
XML Schema
XQL
And All the Rest . . .
How Do I Use It?
SAX
DOM
JAXP
Why Should I Use It?
Java and XML: A Perfect Match
XML Today
XML for presentation
XML for communication
XML-RPC
Business-to-business
XML for configuration
Support for XML
Parsers
Processors
Publishing frameworks
XML editors and IDEs
XML Tomorrow
Configuration repositories
XSP
What’s Next?
2. Creating XML
An XML Document
The Header
XML Instructions
Document Type Declarations
The Content
The Root Element
Identifying XML with Namespaces
XML Data Elements
Element Attributes
Referring to XML “Constants”
Unparsed Data
What’s Next?
3. Parsing XML
Getting Prepared
Obtaining a Parser
Getting the SAX Classes and Interfaces
Have an XML Document on Hand
SAX Readers
Instantiating a Reader
Parsing the Document
Using an InputSource
Content Handlers
The Document Locator
The Start and the End of a Document
Processing Instructions
Namespace Callbacks
Element Callbacks
Element Data
Whitespace, Just the Whitespace
Skipped Entities
The Results
Error Handlers
Warnings
Non-Fatal Errors
Fatal Errors
Breaking the Data
A Better Way to Load a Parser
“Gotcha!”
My Parser Doesn’t Support SAX 2.0: What Can I Do?
The SAX XMLReader: Reused and Reentrant
The Misplaced Locator
Getting Ahead of the Data
What’s Next?
4. Constraining XML
Why Constrain XML Data?
Self-Documentation
Portability
Document Type Definitions
Specifying Elements
Nesting elements
Parsed data
Empty elements
Entity references
Say It Again One More Time
Zero, one, or more
Grouping
Either or
Defining Attributes
Attribute types
To be or not to be
Things Left Out
XML Schema
The Schema Namespace
Specifying Elements
Start at the bottom
User-defined data types
Implicit types and empty content
How many?
Defining Attributes
What’s left out
The definition
Required attributes, default values, and enumerations
What’s Next?
5. Validating XML
Configuring the Parser
Setting Properties and Features
Turning on Validation
Output of XML Validation
Warnings
Non-Fatal Errors
Fatal Errors
The DTDHandler Interface
Unparsed Entity Declarations
Notation Declarations
Registering the Handler
The Rest of the Story . . .
“Gotcha!”
Handling Validation and Handling DTDs
Validate in Development, Cruise in Production
What’s Next?
6. Transforming XML
The Purpose
The Client of the Client of the Client
It’s Greek to Me
The Components
The Extensible Stylesheet Language (XSL)
XSL and trees
Formatting objects
XSL Transformations (XSLT)
XML Path Language (XPath)
The Syntax
XSL Is XML
XSL Templates
Control Structures
Using XPath for filtering
Looping and iteration
Choosing elements to process
Elements and Attributes
Data . . . Just the Data
When Text Just Isn’t Good Enough
What’s Next?
7. Traversing XML
Getting the Output
Getting the Input
SAX Is Sequential
SAX Siblings
Why Use SAX At All?
The Document Object Model (DOM)
The DOM and Java
Getting a DOM Parser
DOM Parser Output
Using a DOM Tree
Getting the ball rolling
Determining a node’s type
The DOM Node Types
The Document node
DOM elements
Applying formatting
Textual nodes
Processing instructions
Document types
Entity references
Mutability of a DOM Tree
“Gotcha!”
Memory and Performance with DOM
DOM Parsers Throwing SAX Exceptions
What’s Next?
8. JDOM
Parsers and the Java API for XML Parsing
Using JAXP with SAX
Using JAXP with DOM
Selecting the Parser to Use
JDOM: Another API?
Specification Slowdown
Java-Optimized
Getting a Document
Starting from Scratch
Building a Document from XML
SAXBuilder
DOMBuilder
Using a Document
The Document DocType
Processing Instructions
Elements
Namespaces
Attributes
Comments
Outputting a Document
Standard XML Output
Firing Off SAX Events
Putting JDOM to Work
What’s Next?
9. Web Publishing Frameworks
Selecting a Framework
Stability
Integration with Other XML Tools and APIs
Production Presence
Making the Decision
Installation
Getting Ant
Getting Cocoon
Building Cocoon
Configuring the Servlet Engine
Using a Publishing Framework
Viewing XML Converted to HTML
Viewing PDFs from XML
Browser-Dependent Styling
WAP and WML
XSP
Creating an XSP Page
Using XSP Tag Libraries
Cocoon 2.0 and Beyond
Servlet Engine Mappings
The Sitemap
Producers and Processors
What’s Next?
10. XML-RPC
RPC Versus RMI
What Is RMI?
What Is RPC?
XML-RPC
Saying Hello
Getting XML-RPC Libraries
Writing the Handler
Writing the Server
Writing the Client
Talk to Me
Putting the Load on the Server
A Shared Handler
A Configurable Server
A Useful Client
Talk to Me (Again)
The Real World
Where’s the XML in XML-RPC?
Shared Instances
To Servlet or Not To Servlet
What’s Next?
11. XML for Configurations
EJB Deployment Descriptors
The Basics
Organization
Creating an XML Configuration File
Getting Started
Organization
Shared information
XML-RPC handlers
Document Constraints
Final Preparations
Reading an XML Configuration File
Getting the Configuration Information
Loading the Configuration Information
Using the Configuration Information
Updating the server
Updating the client
The Real World
XML Versus Databases
XML Versus Directory Services and LDAP
JDOM, SAX, or DOM
SAX
DOM
What’s Next?
12. Creating XML with Java
Loading the Data
An Entry Point for Modification
Displaying the Configuration
Modifying the Data
Updating the Configuration Information
XML from Scratch
The Real World
Threading, Writing, and Arithmetic
JDOM, SAX, or DOM, Revisited
SAX
DOM
Where Did That XmlRpcConfiguration Go?
What’s Next?
13. Business-to-Business
The Foobar Public Library
Evaluating the Requirements
Entering Books
Providing a Listing of Available Books
mytechbooks.com
Filtering the XML Data
XSLT from a Servlet
Push Versus Pull
Rich Site Summary
Creating an RSS XML Document
Validating the RSS Channel
Registering the Channel
Using the Channel
The Real World
XML Versus EDI
RSS Channels: Here to Stay?
What’s Next?
14. XML Schema
To DTD or Not To DTD
Stability of the XML Schema Specification
Enhanced Document Constraints
Namespace Issues with DTDs
Java Parallels
Equivalence
Complementing Java with XML Schema
Pattern Matching
XML-RPC and Distributed Systems
Databases and XML
What’s Next?
A. API Reference
SAX 2.0
Package: org.xml.sax
AttributeList
Attributes
ContentHandler
DocumentHandler
DTDHandler
EntityResolver
ErrorHandler
HandlerBase
InputSource
Locator
Parser
SAXException
SAXNotRecognizedException
SAXNotSupportedException
SAXParseException
XMLFilter
XMLReader
Package: org.xml.sax.ext
DeclHandler
LexicalHandler
Package: org.xml.sax.helpers
AttributeListImpl
AttributesImpl
DefaultHandler
LocatorImpl
NamespaceSupport
ParserAdapter
ParserFactory
XMLFilterImpl
XMLReaderAdapter
XMLReaderFactory
DOM Level 2
Package: org.w3c.dom
Attr
CDATASection
CharacterData
Comment
Document
DocumentFragment
DocumentType
DOMException
DOMImplementation
Element
Entity
EntityReference
NamedNodeMap
Node
NodeList
Notation
ProcessingInstruction
Text
JAXP 1.0
Package: javax.xml.parsers
DocumentBuilder
DocumentBuilderFactory
FactoryConfigurationException
ParserConfigurationException
SAXParser
SAXParserFactory
JDOM 1.0
Package: org.jdom
Attribute
Comment
DataConversionException
DocType
Document
Element
JDOMException
Namespace
NoSuchAttributeException
NoSuchElementException
NoSuchProcessingInstructionException
ProcessingInstruction
Package: org.jdom.adapters
AbstractDOMAdapter
DOMAdapter
Package: org.jdom.input
AbstractBuilder
Builder
DOMBuilder
SAXBuilder
Package: org.jdom.output
XMLOutputter
B. SAX 2.0 Features and Properties
Core Features
Namespace Processing
Namespace Prefix Reporting
String Interning
Validation
Process External Entities (General)
Process External Entities (Parameter)
Core Properties
Lexical Handler
Declaration Handler
DOM Node
Literal (XML) String
Index
Colophon
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Cover
Next
Next Chapter
Preface
Java and XML
Brett McLaughlin
Editor
Mike Loukides
Copyright © 2000 O'Reilly Media, Inc.
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset