← 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:17 | country:PT |
| product:23 | country:PT |
| product:31 | country:PT |
| product:52 | country:DE |
| product:88 | country: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