commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: [JXPath] Custom Functions & the Current Pointer
Date Tue, 21 Apr 2009 14:09:36 GMT

Hi, Andrew.  Your example looks pretty good... what happens exactly when you try it?

-Matt

--- On Mon, 4/20/09, Andrew Hughes <ahhughes@gmail.com> wrote:

> From: Andrew Hughes <ahhughes@gmail.com>
> Subject: [JXPath] Custom Functions & the Current Pointer
> To: "Commons Users List" <user@commons.apache.org>
> Date: Monday, April 20, 2009, 11:31 PM
> Hi there, I think this is a really
> easy question... sorry for this...
> I have created my own function as below....
> 
> package com.blah.function;
> 
> public class Calculate {
>     public static Calculation
> doCalculation(ExpressionContext context, int
> x) {
>         //stuff goes in here...
>     }
> 
> }
> 
> 
> I've  also registered it with the JXPathContext as
> below...
> 
> jxPathContext.setFunctions(new
> PackageFunctions("com.blah.function.",
> "jxpath"));
> 
> 
> I see how this works programatically, but not in an
> expression. For example,
> if I want to find a node and then use that node in
> doCalculation... how?
> 
> '/Something/I/CanFind' then I want to run
> 'doCalculation(6)' on the result
> of the previous query's result.
> 
> 
> I would have thought this would be something like the
> following but I am
> obviously wrong...
> 
> jxpath:Calculate.doCalculation(/Something/I/CanFind,6);
> 
> /Something/I/CanFind[jxpath:Calculate.doCalculation(6)];
> 
> 
> Once an "ExpressionContext" is involved it no longer
> works.
> 
> 
> Any help would be much appreciated :)
> 


      

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


Mime
View raw message