To get all instances ?a of a given class $class, the pattern is
SELECT DISTINCT ?a
WHERE {
?type rdfs:subClassOf* $class .
?a rdf:type ?type .
}
It is not clear to me whether you are looking for instances of a class, or
classes that are instances of a metaclass, or maybe you can clarify in prose
what you mean?
(Also: c? looks incorrect but I guess that was a copy-and-paste problem).
Holger
> On 26 Apr 2023, at 4:52 pm, Julia S. <[email protected]> wrote:
>
> Hi,
> I am trying to customize a SWP script for the first time (7.2.4) and I am
> struggling a little bit.
>
> We have an existing script that does almost exactly what I want based on this:
>
> SELECT DISTINCT ?a ?b ?c
> WHERE { ?a ?b c?.
> ?b a <URI_of_class> .
> }.
>
> So a function is called if ?b is a specific class (specified by it's URI)
>
> I wanted to change this so it uses that class' children instead of the class
> itself and found rdfs:subClassOf.
>
> I tried the following versions, none of which work.
>
> A)
> SELECT DISTINCT ?a ?b ?c
> WHERE { ?a ?b c?.
> ?b rdfs:subClassOf <URI_of_class> .
> }.
>
> B)
> SELECT DISTINCT ?a ?b ?c
> WHERE { ?a ?b c?.
> ?b (rdfs:subClassOf)* <URI_of_class> .
> }.
>
> C)
> SELECT DISTINCT ?a ?b ?c
> WHERE { ?a ?b c?.
> ?b (rdfs:subClassOf)+ <URI_of_class> .
> }.
>
> I double checked if rdfs:subClassOf (including * and +) works on its own
> using a SPARQL endpoint and it gives me the expected instances.
>
> I am guessing I still simply use the wrong syntax for swp scripts or don't
> understand what rdfs:subClassOf actually means.
>
> Any advice?
>
> Cheers
> Julia
>
>
> --
> The topics of this mailing list include TopBraid EDG and related technologies
> such as SHACL.
> To post to this group, send email to [email protected]
> ---
> You received this message because you are subscribed to the Google Groups
> "TopBraid Suite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/topbraid-users/85b221e7-5394-4fc4-900b-d2e2cc6d186cn%40googlegroups.com
>
> <https://groups.google.com/d/msgid/topbraid-users/85b221e7-5394-4fc4-900b-d2e2cc6d186cn%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
The topics of this mailing list include TopBraid EDG and related technologies
such as SHACL.
To post to this group, send email to [email protected]
---
You received this message because you are subscribed to the Google Groups
"TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/606C7BBD-EC19-4B93-988D-8393EF945B15%40topquadrant.com.