You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Tahura Chaudhry <ta...@hotmail.com> on 2004/12/14 03:25:42 UTC

can there be variables in the xpath experession

I am using Xalan-C to evaluate an XPath expression for a given XML document.

Is it possilbe to write an XPath expression with variables and have Xalan-c 
evaluate the expression with supplied values for those variables.

For example, write the expression as:
foo/name[@first=${a} and @last=${b}]

and supply the values 'John' and 'Jane' for the variable '${a}' and the 
values 'Doe' and 'Deer' for the variable '${b}'.

thanks,
Tahura Chaudhry



Re: can there be variables in the xpath experession

Posted by da...@us.ibm.com.
> Is it possilbe to write an XPath expression with variables and have 
Xalan-c 
> evaluate the expression with supplied values for those variables.

It is possible, although it requires deeper hooks into the system than are 
provided by the XPathEvaluator class.  We could provide an enhancement 
that allows for the binding of variables, but I don't know how long that 
would take.  Simple text, numeric, and boolean bindings would fairly easy, 
but node sets would be a bit more difficult.

> For example, write the expression as:
> foo/name[@first=${a} and @last=${b}]

This is not valid XPath syntax, so I don't know what you expect to happen.

Dave