----- Original Message ----- From: "Hallvard Trętteberg" <[EMAIL PROTECTED]> > James, > > > XPath xpath = factory.createXPath( "/x/y/z" ); > > List answer = xpath.selectNodes( document ); > > > > XPath xpath2 = factory.createXPath( "/a/b/c" ); > > List answer = xpath2.selectNodes( document ); > > The disadvantage is that you'll need a factory variable that's "globally" > accessible in your application. Making your own method named createXPath may > just as simple.
Agreed. > You may however simplify this even further, for those who > only need one factory. Introduce a static variable in BaseXPath and a static > method setFactory for setting it. Then add a static createXPath method in > BaseXPath that creates an XPath using this factory. In the code above the > factory variable could then be replaced by 'BaseXPath', and we avoid having > a factory variable (in the case where only one factory is needed). Yes. We could maybe go the JAXP route and have XPathFactory being an abstract base class with a static method that could create 'generic' XPath objects for any model. XPath xpath = XPathFactory.newInstance( "//foo/bar" ); > I still think the XPathFactory idea is good, particularly having a caching > mechanism. Cool James _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest