[MarkLogic Dev General] Referencing a string variable withincts:search

Mattio Valentino mattio.valentino at gmail.com
Tue Jun 26 12:28:23 PDT 2007

Thanks Danny.  That does make more sense.

I did try to change the type of the variable to cts:query while
debugging, but I couldn't get it to work.  I think it's becuase I'm
passing in the value from my app using XCC with:

req.SetNewStringVariable("PARSED_QUERY", qp.ParsedQuery);

Even with the .NET XCC guide, I wasn't able to figure out the proper
syntax to pass a variable of type cts:query.  Any pointers?

On 6/26/07, Danny Sokolsky <dsokolsky at marklogic.com> wrote:
> Hi Mattio,
> I think the key is that you need to define your external variable as
> type cts:query.  Passing in the external variable is definitely the
> preferred technique over using xdmp:eval.  Here is a simple example:
> Suppose you have a file on your app server root named invoke.xqy with
> the following contents:
>   define variable $query as cts:query external
>   xdmp:estimate(cts:search(doc(), $query))
> You can then invoke this XQuery module, passing it a cts:query, by
> issuing a query as follows:
>   xdmp:invoke("invoke.xqy", (xs:QName("query"), cts:word-query("foo")))
> You can have some logic in this module to construct the cts:query to
> make it dynamic (based on user inputs, for example).  For a brief
> example of how you might do that, see the "Creating a cts:query Parser"
> section in the "Composing cts:query Expressions" chapter of the
> Developer's Guide.
> Does that help?
> -Danny

More information about the General mailing list