Conrad Roche has posted Matra 0.8b, an open source Java library for parsing DTDs. It might be useful for some purposes. However, it's divided into way too many packages, and uses short constants for no good reason that I can see. In many cases it should be using type-safe enums instead, or at least ints. Furthermore many methods are exposed as public that really shouldn't be, making the API far more complex than it needs to be. This may well be a symptom of the excessive number of packages. Matra is a read-write API. It's not immedioately clear to what extent the write side of the library maintains the syntactical correctness of DTDs. For instance, does it make sure element names are legal XML names, and does it prevent multiple declarations for the same element? Matra is published under the MPL 1.1.
Dennis Sosnoski has posted JiBX beta 3a, yet another open source (BSD license) framework for binding XML data to Java objects using your own class structures. It falls into the custom-binding document camp as opposed to the schema driven binding frameworks like JaxMe and JAXB. Quoting from the JiBX web site,
JiBX is a framework for binding XML data to Java objects. It lets you work with data from XML documents using your own class structures. The JiBX framework handles all the details of converting your data to and from XML based on your instructions. JiBX is designed to perform the translation between internal data structures and XML with very high efficiency, but still allows you a high degree of control over the translation process.
How does it manage this? JiBX uses binding definition documents to define the rules for how your Java objects are converted to or from XML (the binding). At some point after you've compiled your source code into class files you execute the first part of the JiBX framework, the binding compiler. This compiler enhances binary class files produced by the Java compiler, adding code to handle converting instances of the classes to or from XML. After running the binding compiler you can continue the normal steps you take in assembling your application (such as building jar files, etc.).
The second part of the JiBX framework is the binding runtime. The enhanced class files generated by the binding compiler use this runtime component both for actually building objects from an XML input document (called unmarshalling, in data binding terms) and for generating an XML output document from objects (called marshalling). The runtime uses a parser implementing the XMLPull API for handling input documents, but is otherwise self-contained.
I heard Sosnoski talk about JiBX at SD West a couple of weeks ago. Overall I found it a little too inflexible for my tastes. It assumes a much tighter coupling between XML documents and the corresponding Java classes than I'm comfortable with. It did give me some ides afor a more flexible, loosely coupled framework I may work on in the future.
This beta adds bind-on-load, optional source location tracking for unmarshalling, custom mappings of array classes, and custom marshallers/unmarshallers for DOM or dom4j document models, escaping of output characters based on encoding.