3

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?

scotthenninger
  • 3,921
  • 1
  • 15
  • 24
TJ Tang
  • 921
  • 6
  • 17
  • 1
    Path length does not belong to SPARQL 1.1 And negation `!:p` is supported. – UninformedUser Jun 22 '16 at 14:18
  • As AKSW mentioned, path length (`p{n,m}`) isn't in SPARQL 1.1., though it *was* in [earlier drafts](https://www.w3.org/TR/sparql11-property-paths/) of the property path syntax. http://stackoverflow.com/questions/37489420/boundary-for-arbitrary-property-path-in-sparql-1-1 mentions that some endpoints still support it, and also describes some workarounds. – Joshua Taylor Jun 22 '16 at 18:17

1 Answers1

3

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
Community
  • 1
  • 1
scotthenninger
  • 3,921
  • 1
  • 15
  • 24
  • I had extracted this query as a part or a larger query where there was a union.. so I completely agree in this case that the extra sub select is superfluous. – TJ Tang Jun 22 '16 at 16:30