I’m trying to enhance the jOOX API in a way that it can also operate on JDom documents, not only org.w3c.dom.Document. Instead of duplicating everything, I was wondering if there is any library that implements the interfaces of org.w3c.dom, while at the same time wrapping JDom?
Note, I’m not not looking for org.jdom.output.DOMOutputter, which transforms the JDom document into a DOM document. I suspect that frequent transformations would be very slow. I’m looking for a wrapper, which implements w3c dom with JDom classes.
As part of the JDOM 2.x project I have put together exactly that. It is a read-only wrapper for JDOM in a DOM format. It is comprehensive enough to run JDOM through both the native javax.xml.xpath, as well as Xalan XPath engines…. I have used it extensively as part of the JDOM 2.x test harness.
So, if you are using JDOM 2.0.0, you can overlay the JDOM instances by using the DOM code that is in the ‘contrib’ section.
This is not officially supported JDOM code, but it is probably good enough for your purposes.
See the code at https://github.com/hunterhacker/jdom/tree/master/contrib/src/java/org/jdom2/contrib/dom
The typical usage is:
All the DOM nodes in the returned domdoc also implement the org.jdom2.contrib.dom.Wrapper interface, thus, you can, for example, say:
This code is not officially supported (yet) in the JDOM project…. but it is useful and functional enough.