Domify implements an adapter pattern (GoF, p. 139), providing a W3C DOM interface to an arbitrary graph of Java objects.


XML is a very useful form for data, but it is rare (today, in any case) that data starts out as XML. Java developers find themselves writing code to generate text XML streams from objects like JavaBeans, Collections, and ResultSets. This is laborious work, suffers the risk of malformatting the XML, and requires all data to be checked for special XML characters. Furthermore, if the XML is going to be subsequently processed using XSLT or similar technology, it must be parsed.

Domify eliminates the need to generate XML manually by wrapping Java objects in an adapter which provides a W3C DOM interface. As client code navigates the DOM tree, the Domify code navigates the object graph using introspection.


To use Domify, simply instantiate an instance of DOMAdapter, set any parameters, and call the adapt() method.


DOM trees, are, well, trees, whereas Object graphs can be cyclic. Domify does not check for cycles, so if you have cycles in your object graph, the tree will appear to continue on and on and on and on...

Domify has special handling for java.util.Collection and java.util.Map, converts any of the basic java types (int, Integer, String, etc) to text nodes, and treats everything else as a JavaBean. The next version of Domify will have a pluggable arrangement so that special handling can be applied to any class.

More Information

Domify is open source and freely available; it is covered by an Apache-style license.

Some more sources of information:

You can download Domify from the Sourceforge project page.

Domify was originally written to meet the needs of the Maverick web framework, which allows XSLT to be used as a templating language in the same way that JSP or Velocity can be used.

SourceForge Logo