I am trying to write a SPIN-Rule that will count the number of incoming references and set this number as a property value. E.g., count number of Issues that occurred on a particular machine. Therefore I need to count the number of incoming references of type rdfs:occuredOn (domain: Issue, range: Machine).
CONSTRUCT {
?machine rdfs:numberOfIssues ?n .
}
WHERE {
?machine a ex:Machine .
?issue a ex:Issue .
?issue ?r ?machine .
(COUNT(?r) AS ?n) //Error
}
Thank you in advance!
Only
GroupGraphPatternis allowed, i.e., you have to use a sub-SELECTquery in theWHEREclause:Note, you should never user built-in namespaces/prefixes (such as
owl:,rdfs:,rdf:,xsd:, etc.) for your domain ontology!