3
votes

The MarkLogic semantics documentation mentions that all SPARQL 1.1 property paths are supported, with the exception of negation. I have been unable to get the syntax where path length is specified to work, i.e.

elt{n,m}    A path between n and m occurrences of elt.
elt{n}      Exactly n occurrences of elt. A fixed length path.
elt{n,}     n or more occurrences of elt.
elt{,n}     Between 0 and n occurrences of elt.

If I try something like:

select ?leaf ?distance {
      select  ?leaf (count(?mid) as ?distance) { 
        ?leaf <http://schemas.abbvienet.com/ontologies/infrastructure.owl#manager>{1,2} ?mid .
        ?mid <http://schemas.abbvienet.com/ontologies/infrastructure.owl#manager>{1,2} <http://rdf.abbvienet.com/infrastructure/person/10019933> .
      }
      group by ?leaf
    }

I get the following error:

XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected {

Does this work for anyone else, or does anyone know whether this path syntax is supported or not in MarkLogic?

1
Path length does not belong to SPARQL 1.1 And negation !:p is supported.UninformedUser
As AKSW mentioned, path length (p{n,m}) isn't in SPARQL 1.1., though it was in earlier drafts of the property path syntax. stackoverflow.com/questions/37489420/… mentions that some endpoints still support it, and also describes some workarounds.Joshua Taylor

1 Answers

3
votes

See the SPARQL 1.1 specification for property paths - Note this is different than earlier drafts for SPARQL Property Paths, and in particular the n-to-m occurrences of a property was removed.

You also may find this article useful - boundary for arbitrary property path in SPARQL 1.1.

As an aside, not that the sub-select in your query would be superfluous (if the query worked). The following is equivalent to what you have:

select  ?leaf (count(?mid) as ?distance) { 
    ?leaf <http://schemas.abbvienet.com/ontologies/infrastructure.owl#manager>{1,2} ?mid .
    ?mid <http://schemas.abbvienet.com/ontologies/infrastructure.owl#manager>{1,2} <http://rdf.abbvienet.com/infrastructure/person/10019933> .
}
group by ?leaf