1
votes

After executing the below xquery, resulted in whole content from XML but my objective is to get the list of URI.

let $i := cts:search(//root,
    cts:element-value-query(
        xs:QName("no"),
        "123")) 

return ($i)
1
Please provide a reproducible example, which necessarily includes example input here. - Jens Erat
Have you looked at fn:document-uri Documentation - Michael Gardner
@JensErat i.e.) I have 20 files in marklogic db the above xquery matches 10 files and provides the matched content but what I want is the matched files URI. is this possible or am I not clear. - Antony
see also: cts:uris() - joemfb
@Antony no, this is/was not clear at all. The input could also have contained URIs (that's what I understood the first time reading your question) ... This is a very relevant part of information that should explicitly be listed in the question, also that the content actually spans multiple files, while your query matches only some of them. - Jens Erat

1 Answers

3
votes

If all you want is the URI, use cts:uris(). The 3rd parameter lets you define a query that will filter the URIs list.

So with your example this would work:

cts:uris(
  (), 
  (), 
  cts:element-value-query(
          xs:QName("no"),
          "123")
)