You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Dominique Devienne <dd...@lgc.com> on 2004/04/21 18:00:39 UTC

[JXPath] Outline of creating a custom impl

I've used JXPath in the past to traverse XML documents, and I like it.
Flexible and powerful.

Recently though I've stumbled into a problem with Ant build files. Using the
new Ant 1.6 <import>, which I use liberally, the build is seldom anymore
contained within a single XML document I could simply wrap in a
DocumentContainer. So I'm thinking I could lay a custom JXPathContext
implementation on top of the Ant model (Project / Targets / Tasks /
RuntimeConfigurable) to be able to traverse that module *after* Ant has
resolved all the imports, renames overriden targets, etc...

Ant has a full in-memory model of the build files (which is a slight
approximation of the actual XML nodes, but that's OK for me), so it seems
reasonable to allow traversal of it using JXPath.

Could someone outline the steps necessary to code such a custom pseudo-DOM
tree traversal? The JXPath doc is very brief on what is really needed to do
something like that. Thanks, --DD




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [JXPath] Outline of creating a custom impl

Posted by Dmitri Plotnikov <dm...@apache.org>.
Dominique,

JXPath's own support of a bunch of object models is comprised of different
implementations of the NodePointer and NodePointerFactory APIs.  Consider
following the same approach.  The job of NodePointerFactory is to recognize
the model it supports given an instance of that model. Basically, it answers
a question like "is this a JavaBean?", "is this a DOM node?". The job of
NodePointer is to represent a node in the model and provide iterators of
children, attributes (if any) and namespaces (if any).

Check out the implementations of those APIs in the
org.apache.jxpath.ri.model.* packages and see if any of them would provide a
convenient superclass for your custom model.

Once you have custom NodePointer and NodePointerFactory, register the
factory using the JXPathContextReferenceImpl.addNodePointerFactory() method.

Let me know how it works out.

- Dmitri

----- Original Message ----- 
From: "Dominique Devienne" <dd...@lgc.com>
To: <co...@jakarta.apache.org>
Sent: Wednesday, April 21, 2004 12:00 PM
Subject: [JXPath] Outline of creating a custom impl


> I've used JXPath in the past to traverse XML documents, and I like it.
> Flexible and powerful.
>
> Recently though I've stumbled into a problem with Ant build files. Using
the
> new Ant 1.6 <import>, which I use liberally, the build is seldom anymore
> contained within a single XML document I could simply wrap in a
> DocumentContainer. So I'm thinking I could lay a custom JXPathContext
> implementation on top of the Ant model (Project / Targets / Tasks /
> RuntimeConfigurable) to be able to traverse that module *after* Ant has
> resolved all the imports, renames overriden targets, etc...
>
> Ant has a full in-memory model of the build files (which is a slight
> approximation of the actual XML nodes, but that's OK for me), so it seems
> reasonable to allow traversal of it using JXPath.
>
> Could someone outline the steps necessary to code such a custom pseudo-DOM
> tree traversal? The JXPath doc is very brief on what is really needed to
do
> something like that. Thanks, --DD
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org