← every query · class 09 · queries/alternative-and-sequence.rq

Alternative and sequence in one path

5 rows without the reasoner, 10 rows with it. Switch the regime to see where the difference comes from.

?p?country
product:17country:PT
product:23country:PT
product:31country:PT
product:52country:DE
product:88country:DE

The query

# Alternative and sequence in a property path
# (slide "Aggregation and paths"). onto:distributedBy does not exist in the
# domain yet: the alternative still works, returning only the branch that does.
PREFIX schema: <https://schema.org/>
PREFIX onto:   <https://data.csoares.me/onto#>

SELECT ?p ?country
WHERE {
  # (a|b) = either property; /c = then follow c from wherever that led.
  ?p (onto:manufacturedBy|onto:distributedBy)/onto:country ?country .
}
ORDER BY ?p

Edit it in the query box →