JDOM and XPath API
Rolf <[email protected]>
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Message-ID | <[email protected]> |
Hi All. The XPath code needs some work on the API side of things. The current stat is that there is the class org.jdom2.xpath.XPath. This class performs two basic roles, it is the abstract base for any implemenations that provide XPath processing, and it is also a factory (of sorts) for setting the engine that will service XPaths. The problem is that the Factory-type method is not very useful, for the following reasons: 1. The 'default' factory is not accessible by name (because JaxenXPath is not public). 2. Changing the 'factory' class is system-wide (a static), and means that your entire Java JVM needs to have the same active factory, The bigger problem is that there is no good way to fix this problem without a significant change to the API. What should that change be? I envisage a fix that introduces a classic Factory pattern. This will require removing the factory type methods from the XPath class, to the XPathFactory class. Further, with that change, the XPath class can easily become an interface... which may improve the flexibility of some things. The XPathFactory class can have the same newInstance(), selectNodes() And selectSingleNode() methods which will in turn use a shortcut to the defaultFactory(). But, it can also be used to allow for different implementations of the factory. For reference (perhaps even performance), we should maybe put together an implementation that uses javax.xml.xpath to get the details out of a DOM implementation.... Any comments, concerns? Similarly, the Jaxen engine for XPath has code for 'navigatin' a JDOM document. THis code references org.jdom classes, and we need it to access org.jdom2. This navigation functionality should be re-implemented on the JDOM2 side instead. Rolf _______________________________________________ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/[email protected]