Hi Spike,
No, it probably doesn't work that way. The check on variables is done *before*
the xdmp:value is being executing if you write it like this. I meant using
concat this way:
xdmp:value(concat('cts:search(', $base_context, ', $query)'))
Kind regards,
Geert
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Grobstein, Spike
> Sent: dinsdag 18 augustus 2009 16:35
> To: General Mark Logic Developer Discussion
> Subject: RE: [MarkLogic Dev General] using function parameter
> as contextforcts:search
>
> Thanks Geert,
>
> I'm trying to pass the xpath as a string, so I call like this:
>
> cleanup:find($thirty_days, '/mydocument')
>
> and in the function, I have:
>
> cts:search(xdmp:value($base_context), $query)
>
> I'm still getting the error about being unsearchable.
>
> I don't understand what you mean about using concat() to make
> it a complete expression, though. I assume you meant to put
> the leading / on it?
>
>
> ...spike
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Geert Josten
> Sent: Tuesday, August 18, 2009 10:25 AM
> To: General Mark Logic Developer Discussion
> Subject: RE: [MarkLogic Dev General] using function parameter
> as contextforcts:search
>
> Hi Spike,
>
> I see two options:
> - replace your xpath with some query which can be passed as
> parameter and added to the and-query
> - pass the xpath as a string, use concat to make it a
> complete expression and use xdmp:value to execute the string
> expression
>
> Kind regards,
> Geert
>
> >
>
>
> Drs. G.P.H. Josten
> Consultant
>
>
> http://www.daidalos.nl/
> Daidalos BV
> Source of Innovation
> Hoekeindsehof 1-4
> 2665 JZ Bleiswijk
> Tel.: +31 (0) 10 850 1200
> Fax: +31 (0) 10 850 1199
> http://www.daidalos.nl/
> KvK 27164984
> De informatie - verzonden in of met dit emailbericht - is
> afkomstig van Daidalos BV en is uitsluitend bestemd voor de
> geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen,
> verzoeken wij u het te verwijderen. Aan dit bericht kunnen
> geen rechten worden ontleend.
>
>
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of
> > Grobstein, Spike
> > Sent: dinsdag 18 augustus 2009 16:15
> > To: [email protected]
> > Subject: [MarkLogic Dev General] using function parameter
> as context
> > for cts:search
> >
> > Hi,
> >
> >
> >
> > I'm writing a cleanup function that takes a base context to
> match to
> > find documents that should be deleted:
> >
> >
> >
> > (: returns a sequence of URIs that should be deleted in the
> context of
> > $base_context (ie: /ra_document) that's older than $duration :)
> >
> > declare function cleanup:find($duration as xs:dayTimeDuration,
> > $base_context as node()*)
> >
> > {
> >
> > let $query :=
> >
> > cts:and-query((
> >
> > cts:element-range-query(xs:QName('started_at'), '<=',
> > fn:current-dateTime() - $duration)
> >
> > ))
> >
> > for $doc in cts:search($base_context, $query)
> >
> > return (xdmp:node-uri($doc))
> >
> > };
> >
> >
> >
> > cleanup:find(xs:dayTimeDuration('P60D'), /some_document)
> >
> >
> >
> > ------------------8< snip --------------------------------------
> >
> >
> >
> > When I run that, I get an error that the expression is unsearchable.
> >
> >
> >
> > What I'd like to do is provide a base context to do the
> search on (ie:
> > a document node type).
> >
> >
> >
> > Is there any way to do this?
> >
> >
> >
> >
> >
> > .spike
> >
> >
>
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
> _______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general