Hi, Tim,

I've always had great results using simply the empty sequence. I'd be interested to know if there is any advantage to using cts:query(()).

Also, since this is not reflected in your example, just in case, I'd like to suggest modularizing it a bit, for far easier reading and maintenance--After initializing your variables with a series of a let assignments, create a combined cts:query by calling other functions, like so:

let $combined-query := cts:and-query((
        if ($foo) then search:qry1(...) else (),
        if ($bar) then search:qry2(...) else (),
...
))

The search:qry* functions would return a cts:query type -- basically breaking down each field or fieldset of your form, or some other logical grouping, into separate functions. Then call cts:search(input(), cts:combined-query)

Best,

On Jun 1, 2009, at 3:02 PM, Tim Meagher wrote:

Hi Folks,

Is there a preferred way to build a series of cts:search constructor functions when using conditional (and/or) logic? In the following example I insert a cts:query() if an value is blank, in the other I insert an empty sequence:

cts:search(
  //Record,
  cts:and-query ((
    if ($publisher ne "") then
      cts:element-value-query(xs:QName("Publisher"), $publisher,
("case-insensitive", "diacritic-insensitive", "punctuation- insensitive")
      )
    else cts:query(),
    if ($title ne "") then
      cts:element-value-query(xs:QName("Title"), $title,
("case-insensitive", "diacritic-insensitive", "punctuation- insensitive")
      )
    else ()
  ))
)

Is there a rule for using cts:query() or the empty sequence () for dynamically building cts:search constructors?

Thanks again,

Tim

_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

--
Shannon Scott Shiflett, XML Programmer
ROTUNDA, The University of Virginia Press
PO Box 801079, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: shifl...@virginia.edu   Tel: +1 434 924 4495
Web: http://rotunda.upress.virginia.edu/

_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

Reply via email to