Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 27918 invoked from network); 14 Oct 2002 14:23:09 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 14 Oct 2002 14:23:09 -0000 Received: (qmail 1128 invoked by uid 97); 14 Oct 2002 14:23:54 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 1069 invoked by uid 97); 14 Oct 2002 14:23:53 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 1044 invoked by uid 98); 14 Oct 2002 14:23:52 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: <20021014142304.24891.qmail@web11705.mail.yahoo.com> Date: Mon, 14 Oct 2002 07:23:04 -0700 (PDT) From: Dmitri Plotnikov Reply-To: dmitri@apache.org Subject: RE: Customizing JXPath. Custom Containers. To: Jakarta Commons Developers List In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Kenneth, --- Kenneth Petersen wrote: > Hi. > > After having used a little time looking at the code of package > org.apache.commons.jxpath.ri.model, I have come to the following > conclusion: > > When taking into account that the "only difference" between a bean > like > object and value-objects created by Castor, is that the later defines > many > different kinds of "Collections". That is every time a property named > xxxChoice of bean named xxx, the properties of the type of xxxChoice > is to > be considered as being part of bean xxx. > > I am guessing that all children of a BeanPointer are created using > factory > method NodePointer.newChildNodePointer(NodePointer, QName, Object). > Hence I > could achieve the desired result by adding a new kind of > BeanPointerFactory. > This Factory should be invoked before any of the existing Factories. > Where > are new Factories added? I think you are basically on the right track. Keep in mind that before BeanPropertyPointer creates any children, it needs to be able to produce getPropertyCount(), getPropertyNames() and so forth, so you may need to subclass BeanPropertyPointer in order to rename/flatten these xxxChoice properties created by Castor. > Before beginning to extend the existing bean model, I would very much > like > an understanding of the following: > � When is the NodePointer tree describing the content of a bean > instance actually created? Is it when > JXPathContext.newContext(Object) is > invoked? JXPath does not create a tree, it builds NodePointers as it interprets xpaths. > � What is the entry-point of the model package when the NodePointer > tree is created? It is NodePointer.newNodePointer(...), which is invoked for the root bean of the context. > I am sorry for all the questions, but am hoping for an answer. No, these are quite meaningful questions. I am actually very excited about your project. This might be the first time the core mechanisms of JXPath are being tried out by somebody other than myself. I hope I can help you along the way. > > Best regards > Kenneth Petersen Regards, - Dmitri > > > Kenneth, > > > > There is no separate document for this, but there are several > > examples: > > see all classes in the ..jxpath.ri.model subtree - you have there > > implementations for beans, DOM, JDOM, collections, containers etc. > > > > - Dmitri > > > > > > --- Kenneth Petersen wrote: > > > Dmitri, > > > > > > It is not possible to change the code generated by Castor. > Therefore > > > I will > > > try to implement > > > a NodePointer-NodeIterator-NodePointerFactory. Are there > > any examples > > > or > > > documentation that > > > may help me in this endeavour. > > > > > > Best Regards > > > Kenneth Petersen > > > > > > > Kenneth, > > > > > > > > I am not familiar with Castor enough to give you specific > > > > recommendations, but here are some general ideas. > > > > > > > > 1. The mapping of paths to objects in JXPath is based on the > > > JavaBean > > > > specification. So, I guess I would first look into flattening > > > > properties to make the beans conform strictly to the JavaBean > > > > spec. For > > > > example, if Request had a method like > > > > > > > > public Errors getErrors(){ > > > > return getRequestChoice().getErrors(); > > > > } > > > > > > > > you could get the Errors object (or null) with the > > > "/request/errors" > > > > path. > > > > > > > > 2. If adding code to the Castor-genned classes is not an > option, > > > you > > > > might consider writing a > > > NodePointer-NodeIterator-NodePointerFactory > > > > familiy of classes for specific support of Castor-style > objects. > > > This > > > > may be a little involved, as APIs of those classes, especially > > > > NodePointer, are rather wide. You might be able to inherit > your > > > > implementations from BeanPointer, etc, thus re-using some of > the > > > > JavaBean support for the Castor object. > > > > > > > > Let me know if any of this helps. > > > > > > > > - Dmitri > > > > > > > > > > > > --- Kenneth Petersen wrote: > > > > > Hi. > > > > > > > > > > I am using Castor for creating java objects capable of > > containing > > > > > data > > > > > conforming to certain xsd-schemas. When using Castor to > > > > create a java > > > > > structure capable of containing data of xml entities > following > > > > > schema: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > name="Success" > > > > > type="SuccessType"/> > > > > > > name="Errors" > > > > > type="ErrorsType"/> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Castor creates a "Request" class containing a "RequestChoice" > > > > > container > > > > > containing either a "Success" or "Errors" object. > > > > > > > > > > I would like to use JXPath to access the data of the > > java objects > > > > > using > > > > > X-Path expressions identifying values of the original > > xml-entity. > > > > > Taking the > > > > > example from before, I would like to use expression > > > > "/Request/Errors" > > > > > to > > > > > access the "Errors" children of an xml-entity. I am not > capable > > > of > > > > > doing > > > > > this without being able to configure JXPath so that > > properties of > > > > > classes > > > > > "Xxx" following the naming pattern "XxxChoice" are identifies > as > > > > > being > > > > > containers. Is this at all possible? If so some clues as to > how > > > this > > > > > is > > > > > accomplished would be much appreciated. > > > > > > > > > > Best Regards > > > > > Kenneth Petersen > > > > > > > > > > > > > > > -- > > > > > To unsubscribe, e-mail: > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > > > > > > > > > > > > __________________________________________________ > > > > Do you Yahoo!? > > > > Faith Hill - Exclusive Performances, Videos & More > > > > http://faith.yahoo.com > > > > > > > > -- > > > > To unsubscribe, e-mail: > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > > > > -- > > > To unsubscribe, e-mail: > > > > > > For additional commands, e-mail: > > > > > > > > > > > > __________________________________________________ > > Do you Yahoo!? > > Faith Hill - Exclusive Performances, Videos & More > > http://faith.yahoo.com > > > > -- > === message truncated === __________________________________________________ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com -- To unsubscribe, e-mail: For additional commands, e-mail: