Any idea how to do that exact thing in a cts:query in the additional-query
portion of the search options?

On Mon, May 3, 2010 at 11:57 AM, Andrew Welch <[email protected]>wrote:

> On 3 May 2010 15:46, spig <[email protected]> wrote:
> > I have an additional-query specified in my options to search:search. I
> need
> > to specify a search if an element exists in the XML, but I want to
> discard
> > that as a search if the element does not exist. Specifically I have an
> > expiration date for content and initially I have had additional-query
> > specified like this:
> >
> > <additional-query>
> >       {
> >         cts:and-query((
> >           cts:element-range-query(xs:QName("publicationDate"), "<=",
> > fn:current-date()),
> >           cts:element-range-query(xs:QName("expirationDate"), ">=",
> > fn:current-date()),
> >           cts:not-query(cts:element-query(xs:QName("preview"), "true"))
> >         ))
> >       }
> >       </additional-query>
> >
> >
> > Is there a way to remove the expirationDate element-range-query if there
> is
> > no expirationDate in the document?
>
> The usual idiom for "if nnn exists then nnn else default" is "(nnn,
> default)[1]", so you could use:
>
> (//expirationDate, current-date())[1] ge current-date()
>
> If the expirationDate exists, it will be first in the sequence and get
> selected, otherwise the current-date() will be first and that will be
> selected, which will return true in the test.
>
>
>
> --
> Andrew Welch
> http://andrewjwelch.com
> Kernow: http://kernowforsaxon.sf.net/
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to