commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <>
Subject Re: [JXPath] Custom Extension Functions
Date Wed, 19 Mar 2003 18:43:24 GMT

--- Peter Neumcke <> wrote:
> Hi Dimitri,
> thanks for implementing the Relative Context - we switched to Version
> 1.1
> and it works like a charm!
I am glad to hear that.

> I've got two new questions concerning "Custom Extension Functions":
> * registering
> Registering extension functions with context objects works fine. 
> In the API-Doc of ClassFunctions it is mentioned, that you can
> register
> functions globally by calling 'new ClassFunctions(Integer.class,
> "int")'. In
> the default implementation of JXPathContext the generic functions are
> created with null as namespace, and this seems to prevent generic
> functions
> from returning anything but null:
> private static final PackageFunctions GENERIC_FUNCTIONS = new
> PackageFunctions("", null);
> Did I miss something?
The prefix has nothing to do with the return value of a function.  Each
function is a static method and it can return anything it wants.

> * return values
> I managed to write a function that returns an Integer for later use,
> e.g.
> '[ws:myFunc()]. How would I return Nodes/Pointers/whatever for later
> evaluation, e.g. '[count(ws:myFunc()/preceding-sibling::*)]? What
> type
> should my function return?
I never tested this.  I am not sure it would actually work with either
pointers or actual nodes - oops... I'll look into this as soon as I can
and let you know.
> Thanks for your help,
> Peter


- Dmitri

Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!

View raw message