[MarkLogic Dev General] Referencing a string variablewithincts:search

Danny Sokolsky dsokolsky at marklogic.com
Tue Jun 26 13:56:49 PDT 2007

Ah, I missed the bit about using XCC to pass in the variable, sorry.

To pass this in via XCC, I think you will have to take the approach of
passing in a string (or several strings, if that makes more sense) and
then, on the XQuery side, have code that parses the string(s) into an
appropriate cts:query.  I don't think XCC will currently allow you to
pass in a variable of type cts:query. 

For example, if you have a form that the user uses to enter a search,
you can pass in this string and have the cts:query parsing code turn the
string into a cts:query (like the sample in the doc I mentioned


-----Original Message-----
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of Mattio
Sent: Tuesday, June 26, 2007 12:28 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Referencing a string

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
General mailing list
General at developer.marklogic.com

More information about the General mailing list