Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362688 - dynamic context and atomic values
Summary: dynamic context and atomic values
Status: NEW
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xpath (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jesper Moller CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-02 11:13 EDT by Lukasz Wycisk CLA
Modified: 2012-09-21 20:42 EDT (History)
0 users

See Also:


Attachments
Patch (1.00 KB, text/plain)
2011-11-02 11:14 EDT, Lukasz Wycisk CLA
no flags Details
testcase (1.69 KB, text/plain)
2011-11-02 11:14 EDT, Lukasz Wycisk CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lukasz Wycisk CLA 2011-11-02 11:13:11 EDT
11. According to specification dynamic context contains:
[Definition: The context item is the item currently being processed. An item is either an atomic value or a node.]

[Definition: When the context item is a node, it can also be referred to as the context node.] 

The context item is returned by an expression consisting of a single dot (.). When an expression E1/E2 or E1[E2] is evaluated, each item in the sequence obtained by evaluating E1 becomes the context item in the inner focus for an evaluation of E2.


In current implementation it is not possible to pass atomic values to evaluator since it is filtered for org.w3c.Node implementations. Older approach is even worst since it allows only DocType to be context node.

Test: DynamicContextValueTest.testDynamicContextValue() shows this problem.
Comment 1 Lukasz Wycisk CLA 2011-11-02 11:14:10 EDT
Created attachment 206342 [details]
Patch
Comment 2 Lukasz Wycisk CLA 2011-11-02 11:14:27 EDT
Created attachment 206343 [details]
testcase
Comment 3 Lukasz Wycisk CLA 2011-11-02 11:18:32 EDT
Fix is simple since evaluator accepts every Object it can be additionally filtered for Item objects. It will work with current tests however we think Object[] parameter will probably cause many problems. 

Do you think the evaluation method can be changed to accept only Item[]? It is easy to create one since NodeType.dom_to_xpath is public. There can also be another method with Node[] parms for current use.
Comment 4 Jesper Moller CLA 2012-09-21 20:42:17 EDT
I'd go further, by allowing "standard" Java values as the context item, supporting string, misc. numeric types, QNames, etc. For that, we'd need an ItemFactory, replacing NodeType.dom_to_xpath, and allow advanced users to override it, e.g. by putting it into the DynamicContext, or perhaps even passed in to the EvaluationContext.

Such an ItemFactory would also help out when adding variables to the DynamicContextBuilder.

Is that too far out?