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

Alternative and sequence in one path

5 rows without the reasoner, 10 rows with it. The highlighted rows exist only under OWL 2 RL.

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

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 →