I am using ML version 8.0-6.3
What I need is to pass sequence of IRIs
as values in binding variable to sem:sparql
which will be used in filter
clause.
for example:
let $params :=
map:new((
map:entry("narrowersQuery", ("term:56564", "term:56564"))
))
return
sem:sparql(
"
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX term: <http://www.test.com/term/>
SELECT ?iri ?pl
WHERE {
?iri skos:prefLabel ?pl .
?iri skos:narrower ?narrower .
filter (?narrower in (?narrowersQuery))
# ?narrowersQuery should be treated as (term:56564, term:56564)
} limit 10
",
$params
)
Above query should return the IRIs having narrower predicate objects in (term:56564, term:56564) sequence.
Please help me if there is any way to achieve this.
I came across sem:sparql-values
but that one is also not working, might be I am using that function in the wrong way.
I typically use the =
rather than the IN
operator for this, which has done the trick for me in various occasions.
You likely also want to pass in sem:iri
's, rather than strings, something like this:
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
declare namespace term = "http://www.test.com/term/";
let $params :=
map:new((
map:entry("narrowersQuery", (sem:curie-expand("term:56564"), sem:curie-expand("term:56564")))
))
return
sem:sparql(
"
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?iri ?pl
WHERE {
?iri skos:prefLabel ?pl .
?iri skos:narrower ?narrower .
filter (?narrower = ?narrowersQuery)
} limit 10
",
$params
)
HTH!