JDOM
Intro to JDOM
Where we're going
Prerequisites
A simple example
Document Type Definition
Trees
Processing XML with Java is easy
What is JDOM?
About JDOM
JDOM versions
Four packages:
The org.jdom package
The org.jdom.input package
The org.jdom.output package
The org.jdom.adapters package
Part II: Writing XML Documents with JDOM
A JDOM program that writes this XML document
Hello JDOM
Actual Output
Hello DOM
A Java program that writes Fibonacci numbers into a text file
fibonacci.txt
fibonacci.xml
A JDOM program that writes Fibonacci numbers into an XML file
A DOM program that writes Fibonacci numbers into an XML file
Changing Encoding
Suppose you want to include a DTD
ValidFibonacci
valid_fibonacci.xml
Using Namespaces
With Namespace Prefixes
The Default, Unprefixed Namespace
With Default Namespace
Converting data to XML
Sample Tab Delimited Data: Baseball Statistics
A Program to convert tab delimited data to XML
Baseball Stats in XML
A Shortcut
Converting data to XML while Processing it
Batting Averages in XML
Advantages of JDOM for Writing Documents
Part III: Parser APIs
Parser APIs
JDOM Compatible Parsers for Java
SAX
SAX2
The SAX Process
Event Based API Caveats
Document Object Model
The Design of the DOM API
DOM Evolution
Eight Modules:
DOM Trees
org.w3c.dom
The DOM Process
The JDOM Process
Parsing a Document with JDOM
Parser Results
Turning on Validation in JDOM
JDOM Validator
Validation Output
Building with DOM instead of SAX
DOMBuilder Example
Schemas
Part IV: Reading XML Documents
UserLand's RSS based list of Web logs
Goal: Return a list of all the URLs in this list as java.net.URL objects
The SAX ContentHandler interface
SAX Design
User Interface Class
ContentHandler Class
Weblogs Output
Weblogs with DOM
DOM Design
The Node Interface
The NodeIterator Interface
The NodeFilter Interface
Weblogs with DOM
Weblogs Output
Weblogs with JDOM
JDOM Design
Weblogs with JDOM
Weblogs Output
Part V: The org.jdom Package
The Document Node
The Document Class
Document Example
Output from XMLPrinter
Element Nodes
Element Class Implementation
The Element Class
Element Example: XCount
XCount Output
Handling Attributes in JDOM
The Attribute Class
IDTagger
Before IDTagger
After IDTagger
Handling Entities in JDOM
The Entity Class
Handling Comments in JDOM
The Comment Class
Comment Example
CommentReader Output
ProcessingInstruction Nodes
The ProcessingInstruction Class
XLinkSpider that Respects the robots Processing Instruction
Handling Namespaces
The Namespace Class
The Namespace Class
DocType Nodes
The DocType class
Example of the DocType Class
XHTMLValidator
Using the XHTMLValidator
The Verifier Class
The Verifier Class
JDOMException
JDOMException Class
Part V: The org.jdom.output Package
Serialization
XMLOutputter
Using the XMLOutputter Class Directly
Using the XMLOutputter Class Indirectly
JDOM based TagStripper
Output from a JDOM based TagStripper
Talking to DOM Programs
Talking to SAX Programs
Part VI: The org.jdom.input package
SAXBuilder
DOMBuilder
What JDOM doesn't do
To Learn More
Questions?
Entire Presentation as Single File
Start
|
Cafe con Leche
Copyright 2000
Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified August 5, 2000