JDOM Makes XML Easy: Jason Hunter
JDOM Makes XML Easy: Jason Hunter
Jason Hunter
Co-Creator
JDOM Project
Session #2105
JDOM Makes XML Easy
4 Session #2105
Introductions
6 Session #2105
The JDOM Project
• JDOM is...
– A programming model to represent XML data
– Similar to the DOM but not built on DOM or
modeled after DOM
– An open source project with an Apache
license and 2000+ list subscribers
– A Java Specification Request (JSR-102)
7 Session #2105
The JDOM Philosophy
org.jdom
org.jdom.input
org.jdom.output
org.jdom.adapters
org.jdom.transform
10 Session #2105
The JDOM Classes
11 Session #2105
The JDOM Classes
12 Session #2105
General Program Flow
Database Graphics
JDOM
Document
DOM Nodes DOM Nodes
13 Session #2105
JAXP and TRaX
14 Session #2105
The Document Class
15 Session #2105
JDOM vs DOM
16 Session #2105
JDOM vs DOM
// Raw output
outp.output(doc, fileOutputStream);
// Compressed output
outp.setTextTrim(true);
outp.output(doc, socket.getOutputStream());
// Pretty output
outp.setIndent(" ");
outp.setNewlines(true);
outp.output(doc, System.out);
18 Session #2105
The Element Class
20 Session #2105
Moving Elements
21 Session #2105
Well-Formedness
LegalRoot
22 Session #2105
Well-Formedness
Child1 Child2
23 Session #2105
The Attribute Class
// Get an attribute
String width = table.getAttributeValue("width");
int border = table.getAttribute("width")
.getIntValue();
// Set an attribute
table.setAttribute("vspace", "0");
24 Session #2105
Element Content
25 Session #2105
Element Content
26 Session #2105
Mixed Content
27 Session #2105
More Mixed Content
28 Session #2105
Processing Instructions
29 Session #2105
Namespaces
30 Session #2105
Current Status
31 Session #2105
Changes in Beta 8
32 Session #2105
Success Story
33 Session #2105
JDOM as a JSR
34 Session #2105
What It Means
• http://java.sun.com/aboutJava/communityprocess
/jsr/jsr_102_jdom.html
35 Session #2105
The People
36 Session #2105
Get Involved!
37 Session #2105
Summary
38 Session #2105
Session #2105
Session #2105