hoijui
hoijui

Reputation: 3914

List URIs and recursive blank-nodes of properties within a namespace

I want to get a list of all the classes/datatypes and for each, a list of all the predicates fro the sh: (e.g. sh:or, sh:node, ...) and the corresponding objects. I got it working for URI objects, but not for blank nodes which might have other sub-blank-nodes.

PREFIX owl:     <http://www.w3.org/2002/07/owl#>
PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sh:      <http://www.w3.org/ns/shacl#>

SELECT ?s ?pSh ?oSh
WHERE {
    {
        {
            VALUES ?t {
                rdfs:Class owl:Class rdfs:Datatype
            }
            ?s rdf:type ?t .
        }
        UNION
        {
            ?s rdfs:subClassOf ?o .
        }
    } .
    OPTIONAL {
        ?s ?pSh ?oSh .
        filter (strstarts(str(?pSh), str(sh:)))
    } .
}
GROUP BY ?s ?pSh ?oSh
ORDER BY ?s

I tried to combine it with the code from this answer regarding recursive blank node fetching: https://stackoverflow.com/a/72031892/586229

but no luck so far.

Upvotes: 0

Views: 42

Answers (0)

Related Questions