Hi Mattio,
The answer depends on how simple or complex you need your query to be. A
simple approach to satisfy just the above could be:
(Assume $query is your external variable)
let $query := "view, contents"
return cts:search(//LINE, cts:and-query(tokenize($query, ", ")))
This assumes you always want to AND your keywords.
You could pass in XML representing your query and parse it:
define function get-query($query as element(query)) as cts:query {
let $query-body := $query/*
return
typeswitch($query-body)
case element(and) return process-and-query($query-body)
(: process or query :)
default return error("Invalid query type")
}
define function process-and-query($and-element as element(and)) as
cts:and-query {
cts:and-query(data($and-element/word))
}
let $query :=
<query><and><word>view</word><word>contents</word></and></query>
return cts:search(//LINE, get-query($query))
You can use xdmp:unquote() to turn your xml sting passed in via your
external variable into a document node.
You might even want to take a look at:
http://www.w3.org/TR/xquery-full-text/#id-xqft-xqueryx
Cheers,
Lee
On 26/06/07, Mattio Valentino <[EMAIL PROTECTED]> wrote:
....
But, is there a more proper or efficient way to pass in this variable
so it can be referenced inside of cts:search? Or is there a way to
convert it properly using XQuery?
Thanks!
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general