Thank you very much for your patience.

I'll try to be more thorough this time.

I want to give my users the ability to write XPath expressions that refer to
some XML input. There is no XSLT involved, just displaying the results.

The user should be abe to use some pre-defined variables: some are global,
and some depend on the document meta-data and on other things that i am able
to calculate. For example, i want to user to write "/pers...@name ==
$USERNAME]/@password".

My plan is to use XPathEvaluator::evaluate(), but before calling it I want
to change the context node so that $USERNAME will be meaningful. Reading
xpath documentaion in w3c, i thought there would be some obvious way to do
such things.

At first I thought I can overcome it by changing the syntax a little and
introducing a function, e.g.

"/pers...@name == env.getValue("USERNAME")]/@password"

But I realized that I can't write this function - my code should be
thread-safe, and each thread may have different users, so there is no way I
can find the user name, short of using Thread-Local Storage.

Another way is, I think, to add things to the DOM instead of variables. then
the user may write

"/pers...@name == /envValues/@USERNAME)]/@password"

This is ugly, though. So I still hope I can avoid it.

Thanks, Moddy.





David Bertoni-2 wrote:
> 
> On Fri, Feb 6, 2009 at 1:40 AM, Moddy Te'eni <mte...@informatica.com>
> wrote:
> 
>>
>> Ah, So I got it wrong.
>>
>> Anyway, what I'm looking for is a way to set user-defined variables. I
>> don't
>> see any API that creates them, accept by using XSLT.
> 
> Yes, there are APIs that do that, depending on the context.  For example,
> user-installed functions can create variables, which you can see by
> looking
> at the implementations of the EXSLT functions in src/xalac/XalanEXSLT.
> 
> If examining the source code for those functions doesn't answer your
> question, please be more specific about what you're trying to do.
> 
> Dave
> 
> 

-- 
View this message in context: 
http://www.nabble.com/creating-variables-for-XPath-tp21823462p22154274.html
Sent from the Xalan - C - Users mailing list archive at Nabble.com.

Reply via email to