|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Dynamic return contentMartin Probst mail at martin-probst.comTue Sep 28 09:24:54 PDT 2010
> The above attempt assumes an evaluate() extension function smart enough to
> know about the variable $document. I've tried it with xDB and it doesn't
> work. I have yet to try it with eXist. I have not found a way to do this
> with standard XQuery. It would be useful to have as this dynamically limits
> the serialization of the result document. Does anyone know how to do this?
In xDB, this is impossible with the evaluate function (xhive:eval in
this case). Eval creates a complete new query, so it doesn't inherit
any of the variables or other static context settings. The main reason
for that is that we don't have access to variable names at runtime,
they are all resolved, and evaluating every variable even if it is
unused, just because it _might_ be used in an eval clause seems
cumbersome.
What you can always do is implement this either as an external (Java)
function, or as an internal XQuery user defined function:
declare function local:follow-paths($context as node()*, $steps as
xs:QName*) as node()*
{
if (not($steps)) then $context
else
let $first := $steps[0]
return local:follow-paths($context/(* | @*)[node-name(.) eq
$first], subsequence($steps, 2))
};
Note that this takes QNames, and paths need to be split on the '/'.
And of course it doesn't do generic XPaths.
Regards,
Martin
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








