commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Heaberlin" <heabd...@gmail.com>
Subject Re: Calling a method with JXPath
Date Sun, 04 Mar 2007 19:29:41 GMT
Try passing the object on which you want to call the method as the
first arg in the xpath function (the object's method).

.[1]/getQuestion(.[1], 'lastname')

Object methods take the syntax above as part of JXPath's standard
extension functions.

http://jakarta.apache.org/commons/jxpath/users-guide.html#Standard_Extension_Functions

Hope this helps,

-Scott Heaberlin

On 3/3/07, Neil Benn <neil.benn@ziath.com> wrote:
> Hello,
>
>
>
>             I have a a strane problem when I'm trying to call a method with
> JXPath.  The object graph has a user which has a method called
> getQuestion(String pstrQuestionID).  The JXPath I have written for this is:
>
>
>
> .[1]/getQuestion(\'lastname\')
>
>
>             The dot at the front is notation to allow me to access the first
> element, the root of the context is a list.  However when I attempt to run
> this I get the following stack trace :
>
>
>
> org.apache.commons.jxpath.JXPathException: Invalid XPath:
> '.[1]/getQuestion(\'lastname\')'. Syntax error after: '.[1]/g'
> org.apache.commons.jxpath.ri.Parser.parseExpression(Parser.java:60)
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.compileExpression(JXPathContextReferenceImpl.java:218)
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getValue(JXPathContextReferenceImpl.java:247)
>
>
>             However as far as I can see, the XPath notation is valid – I would
> be most grateful is someone could let me know what I've done wrong.
>
>
>
>             Thanks, in advance for your help.
>
>
>
> Cheers,
>
>
>
> Neil
>
>
>
> ---
>
> Neil Benn Msc
>
> CEO Ziath Ltd
>
> Website - http://www.ziath.com
>
> Blog - http://labauto-lounge.com
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message