Skip to content

How to match all (SHACL) instances of a class in Rules? #961

Description

@HolgerKnublauch

The current Rules draft appears to limit Path expressions to those with fixed length, but zero-or-more is not supported.

I wonder how we can then match all instances of a given class and its subclasses, which is usually done using

SELECT ?instance
WHERE {
    ?instance rdf:type/rdfs:subClassOf* ex:SomeClass .
}

Among other use cases, this is important for scenarios where a property is not sufficient to distinguish class membership. For example, when you want to define a rule on rdfs:label that only applies to instances of some class but not all (although rdfs:label is used everywhere).

This topic also relates to #765.

Maybe there is a need for a construct such as INSTANCEOF, which would address the a/rdfs:subClassOf* use case at least?

RULE { ... }
WHERE {
    ?instance INSTANCEOF ex:SomeClass .
    ?instance rdfs:label ?label .
    ...
}

Other usages of zero-or-more-paths exist are probably less critical than getting the instances.

(FWIW I think something like INSTANCEOF would be nice in SPARQL in general).

Metadata

Metadata

Assignees

No one assigned

    Labels

    RulesFor SHACL 1.2 Rules spec.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions