----- Original Message ----- From: "Philip Nelson" <[EMAIL PROTECTED]> > > > // create an X from somewhere either via > > X doc = new Xdom4j( aDocument ); > > > > // use an empty X to start with... > > X x = X.create(); > > X doc = x.eval( "document('/a/b/c.xml' )" ); > > A variation on this idea I think would be useful would be > > List expressions = new ArrayList(); > //add a bunch 'o xpath statements to list > XMLFilter filter = x.createFilter(expressions); > > //use the filter with underlying library
I think that'd be a great addition. Though I think that comes under the more general topic 'a SAX XPath filter' which anyone using SAX or one of the doms could use, whether the 'X' API existed or not. It'd be a nice standard feature whenever anyone is parsing a dom to avoid creating parts of the tree you don't want (or only parse parts of the tree you want). BTW the '|' notation could be used so that only a single XPath expression is needed, instead of the List. e.g. foo | bar | *@ | */toto could be represented in a single String. So just XMLFilter filter = x.createFilter(String expression); would do. The problem with evaluating XPath expressions at the SAX level is you only get one element start or one element end or a frament of text at once, there's no 'model' - so sometimes the above approach might need to delegate down to a real model like DOM/dom4j/EXML/JDOM etc. Maybe Xalan is good enough these days so that the above could be implemented as a stylesheet or translet? I think there could well be room for a new simple, optimised 'dom' which is only used to implement a Jaxen Navigator and is tuned specifically for XPath evaluations (a bit like Xalan & Saxon have their own models for XSLT), maybe this 'jaxen' model could be used by the SAX XPath filter to make some nodes if its required. e.g. so that QName or localName comparisons could be integer equality tests rather than the more expensive String comparisons. 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