I'm watching to see if ML has an opinion on your () vs.
cts:query(()) question! As to the modularized approach, I realize
your example didn't call for it, and you're probably already using
that strategy in your production code, but I thought I'd mention it
in case it would help somebody watching the discussion.
On Jun 1, 2009, at 3:35 PM, Tim Meagher wrote:
Hi Shannon,
Thanks, and yes, I like the modularized approach too!
Tim
________________________________
From: [email protected]<mailto:[email protected]
> [mailto:[email protected]] On Behalf Of
Shannon
Sent: Monday, June 01, 2009 3:32 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Building cts:search queries
withconditional logic
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
[email protected]<mailto:[email protected]
>
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: [email protected]<mailto:[email protected]> Tel:
+1 434 924 4495
Web: http://rotunda.upress.virginia.edu/
_______________________________________________
General mailing list
[email protected]<mailto:[email protected]
>
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: [email protected]<mailto:[email protected]> Tel:
+1 434 924 4495
Web: http://rotunda.upress.virginia.edu/