Greg, --- Greg <[EMAIL PROTECTED]> wrote: > All, > > I'm trying to plug in a general purpose DOM AbstractFactory that will > handle creation of elements/attributes as needed. > > > JXPathContext context = JXPathContext.newContext( myDomElement ); > > AbstractFactory factory = new MyJXPathDOMFactory(); > context.setFactory(factory); > context.setLenient(true); > > where myDomElement does contain <someElement> but not <fred> or @fred > the following lines fail without calling my factory (which contains > printlines to show where the createObject and declareVariable methods > are called. > > context.createPath( "//someElement/fred" ); // fails > context.createPath( "//someElement/@fred" ); // fails > > I get the following exception: > > JXPathExpression: Expression is not a path > at > org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.createPathJXPathContextReferenceImpl.java:361)
I have improved the error reporting since b1. You will see the new error message in b2. Here's the text of the message: "JXPath can only create a path if it uses exclusively the child:: and attribute:: axes and has no context-dependent predicates" In your case you are using the descendent-or-self:: axis. JXPath does not know how (or where in tree) to create the missing nodes. > > > 1. Is there a *simple* example floating around that in a few lines of > code shows how a custom AbstractFactory is plugged into a > JXPathContext using DOM? There are several factories in the test tree. See for example org.apache.commons.jxpath.ri.model.dom.TestDOMFactory. > 2. Is there already an implementation of a general purpose DOM > AbstractFactory available anywhere? Not that I know of. > Thanks, > Greg. > Regards, - Dmitri __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
