JDOM is a pure Java API for processing XML documents. It is more complete than either SAX (which doesn’t offer any standard way to write new XML documents) or DOM (which can manipulate XML documents but doesn’t know how to parse or serialize them). It is also much easier to use than either SAX or DOM for most tasks. It has the convenience of a pull-based tree API with DOM and the familiarity of following standard Java conventions with SAX. However, JDOM is not SAX and it is not DOM. JDOM can transfer data to and from SAX and DOM, but it is its own API, complete unto itself.
JDOM uses concrete classes rather than interfaces. This means you can create instances of most of the node types just by passing an argument or two to a constructor. (The notable exception is the Namespace class which uses a factory method in order to implement the flyweight design pattern.) For instance, to create a new Element object for a number element, you simply type
Element element = new Element("number");
Node objects do not need to be attached to any document. However, an object can’t be part of more than one document at a time.
JDOM Document objects can also be created by parsing an existing file. This is done by the SAXBuilder class which relies on a SAX2 parser such as Xerces. JDOM Document objects can also be built from existing DOM Document objects through the DOMBuilder class. Moving in the other direction, the XMLOutputter class can serialize a JDOM Document object onto a stream. The SAXOutputter class can feed a JDOM Document into a SAX ContentHandler, and the DOMOutputter class can convert a JDOM Document into a DOM Document.
|Copyright 2001, 2002 Elliotte Rusty Haroldemail@example.com||Last Modified April 19, 2002|
|Up To Cafe con Leche|