Community
Participate
Working Groups
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.
Created attachment 206342 [details] Patch
Created attachment 206343 [details] testcase
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.
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?