JDOM, The Java DOM (4/4) - exploring XML | WebReference

JDOM, The Java DOM (4/4) - exploring XML

JDOM, The Java DOM

JDOM summary

Handling Attributes in JDOM

In JDOM, each attribute is represented as an Attribute object, which as a string name and a string value, plus a Namespace object (which may be Namespace.NO_NAMESPACE). Convenience methods can convert the attribute value to various types like int or double. JDOM enforces restrictions on attribute names and values. Attributes are stored in a java.util.List in the Element that contains them.

Handling Namespaces

Namespaces are represented by instances of the Namespace class rather than by attributes or raw strings. Always ask for elements and attributes by local names and namespace URIs, never identify an element or attribute by its qualified name, such as <vml:line>. Elements and attributes that are not in any namespace can be asked for by their local name alone.

JDOM limitations

JDOM, like all other current DOM implementations, constructs its documents in memory, so documents that are larger than available memory cannot be parsed. JDOM does not create identical, only equivalent documents when parsing and rewriting XML documents. It does not deal with DTDs as they are not XML documents, although the underlying validating parser uses them, of course. XPath Queries for navigating an XML document are announced for version 1.1.


JDOM is a convenient interface for Java programmers to have XML documents presented in a more Java-like fashion, reusing Java libraries and design patterns. Version beta 5 is out, have a look if you want to quit struggling with the comparatively awkward W3C DOM Java binding.


Produced by Michael Claßen
All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/xml/column25/4.html
Created: Dec 03, 2000
Revised: Dec 03, 2000