This is good to know. I never would have thought of util:eval since I tend to reflexively avoid it at all costs, but it does seem a good fit for the general problem. I can see that one would have to be careful of the potential security ramifications, so I'll think about this for future projects for now. Thanks for the replies!

On Tue, Jul 31, 2012 at 10:34 AM, Joe Wicentowski <joewiz@gmail.com> wrote:
Hi Dave,

> My question is, is there a better way to run this query without having to
> unroll it like this? Here's my eXist version information:

This sounds like a good use case for util:eval().  You'd construct the
XPath expression dynamically as a string and then use util:eval() to
execute the expression.

  let $path := concat('$xml-doc//', '$filter')
  let $filter-nodes := util:eval($path)

For security reasons you'd want to be sure you carefully controlled $filter.

Cheers,
Joe



--
David Finton