On 03/14/2012 07:44 PM, Charles Duffy wrote:
Howdy --
Right now, I'm aware of two ways to set the context item via the native protocol:
(1) Insert a "declare context item" header into the document
- Disadvantage: Should only work when XQUERY3 is true
- Disadvantage: Modifies line/column references for errors received
- Disadvantage: Hard to ensure that user-provided XML document will
evaluate to itself in XQuery (security risk)
Bigger disadvantage: ContextItemDecl is allowed only in the second portion of the prolog, so inserting this unambiguously would require parsing the 3rd-party document. Ugh.
(2) Use the "CS" ["Context Set"] command
- Disadvantage: Requires a database to be open (why?)
- Disadvantage: Hard to ensure that user-provided XML document will
evaluate to itself in XQuery (security risk)
I really should have tested before considering this feasible:
CS <root/>
[BASX0007] Query must yield database nodes.