Java XML – JDOM2 – Introduction

What is JDOM

JDOM is an in-memory XML model that can be used to read, write, create and modify XML Documents. JDOM is similar to DOM in that they both provide an in-memory XML document model, but while DOM is designed to work the same in multiple languages (C, C++, ECMAScript, Java, JScript, Lingo, PHP, PLSQL, and Python []), JDOM is designed only for Java and uses the natural Java-specific features that the DOM model avoids. For this reason JDOM intentionally does not follow the w3c DOM standard. JDOM is not an XML parser but it can use a SAX, StAX or DOM parser to build the JDOM document. JDOM versions since JDOM 2.0.0 (JDOM2) all use the native language features of Java6 and later like Generics, Enums, var-args, co-variant return types, etc.

In the tutorials listed below we provide you with examples of all key functionalities of JDOM2. However before you start seeing the examples, it would be a good idea to understand the main packages that form part of JDOM2 and the functionalities that each of the packages provide. The first tutorial in the series provides an introduction to the package structure along with important classes in each package. The subsequent tutorials provide examples for each of the key functionalities.

  1. JDOM2 package structure – Introduces the package structure and explains the important classes that form the API
  2. JDOM2 Usage – An introduction to building and using JDOM2 Document.
  3. SAXBuilder Example
  4. SAXBuilder with DTD validation
  5. SAXBuilder with XSD validating – This tutorial explains how create a JDOM2 from an XML using a SAX parser by validating the document using an XSD. The example explains how to validate using an internal XSD as well as an external XSD
  6. SAXBuilder – A discussion on various components of SAXBuilder and ways to configure it
  7. DOMBuilder – A tutorial on building a JDOM2 document from a w3c Document using DOMBuilder.
  8. Building JDOM2 using StAX
  9. Filters
  10. Namespaces
  11. Outputter – In this tutorial we learn how to output JDOM2 as XML, DOM, SAX, StAXEvent and StaxStream
  12. Transforming the JDOM2 document using XSL
  13. Querying a JDOM2 document using Xpath

– We thank
Rolf Lear
for reviewing the tutorials and giving us a detailed feedback on the pages.

If you like the tutorial then please put in your comments and also ‘like’ us on facebook or follow us on google.

1 thought on “Java XML – JDOM2 – Introduction”

Leave a Comment