[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Dynamic return content

Martin Probst mail at martin-probst.com
Tue Sep 28 09:24:54 PDT 2010


  Dynamic return content
> 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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.