Hi Florent,

Have you looked into cts:element-query? You pass it a sub query that will be 
constrained to the contents of an element with that name. Something like:

Cts:element-query(xs:Qname("foo"), cts:element-value-query(xs:QName('bar'), 
'one'))

Note though: it is not identical; it also matches bar descendants that are not 
direct child of foo.

Kind regards,
Geert

>


drs. G.P.H. (Geert) Josten
Consultant

Daidalos BV
Hoekeindsehof 1-4
2665 JZ Bleiswijk

T +31 (0)10 850 1200
F +31 (0)10 850 1199

mailto:geert.jos...@daidalos.nl
http://www.daidalos.nl/

KvK 27164984


De informatie - verzonden in of met dit e-mailbericht - 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: general-boun...@developer.marklogic.com
> [mailto:general-boun...@developer.marklogic.com] On Behalf Of
> Florent Georges
> Sent: vrijdag 12 november 2010 12:52
> To: MarkLogic General ML
> Subject: [MarkLogic Dev General] CTS search: using a precise path
>
>   Hi,
>
>   When using cts:element-value-query, we match any descendent
> of a given name.  Is there any way to restrict the position
> of a matching element, e.g. to be a grand-child of a given child?
>
>   Context and example: I am using a CTS search to search
> through the entire database.  Let's say I have documents of the form:
>
>     <doc>
>        <foo>
>           <bar>...</bar>
>        </foo>
>        <fooz>
>           <baz>...</baz>
>        </fooz>
>     </doc>
>
>   So if I want to get all doc elements where foo/bar is equal
> to 'one', I can use the following:
>
>     cts:search(
>       /doc/foo,
>       cts:element-value-query(xs:QName('bar'), 'one'))/..
>
>   If I want the doc elements where foo/bar is equal to 'one'
> and where fooz/baz is equal to 'two', I can use the following:
>
>     cts:search(
>       /doc,
>       cts:and-query((
>         cts:element-value-query(xs:QName('bar'), 'one'),
>         cts:element-value-query(xs:QName('baz'), 'two'))))
>
>   This search is fine as long as we have bar elements only at
> the exact position /doc/foo/bar, and as long as we have baz
> elements only at the position /doc/fooz/baz.  If they can be
> at different locations, then the search will return false positive.
>
>   I can of course filter them again using plain predicates,
> but that's really doing twice the same work and that works
> only if there are not 1 zillion false positive matches.  So
> the questio
> is: is there anything equivalent to the following, to anchor
> exactly a match within its parent/ancestor:
>
>     cts:search(
>       /doc,
>       cts:and-query((
>         cts:path-value-query('foo/bar',  'one'),
>         cts:path-value-query('fooz/baz', 'two'))))
>
>   Regards,
>
> --
> Florent Georges
> http://fgeorges.org/
>
>
>
>
>
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to