sparqlrdfschema.orgrdfsrdflib

SPARQL query returns 0 results when querying specific value in array


I am new to RDF and SPARQL, so i want to list all the Properties that https://schema.org/ListItem can have for example. This is the turtle file for https://schema.org/version/latest/schemaorg-current-https.ttl I am using RDFlib in python https://rdflib.readthedocs.io/en/latest/index.html

I am running this code but i get 0 results:

q =  """
    PREFIX schema: <http://schema.org/>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    
    SELECT DISTINCT ?label
    WHERE {
        ?s a rdf:Property ;
            schema:domainIncludes ?domain ;
            rdfs:label ?label .
        FILTER(?domain = "http://schema.org/ListItem")
    }
    """

for r in g.query(q):
    print(r)

When i run the query without schema:domainIncludes i get all the Properties for all schema types, like this:

    PREFIX schema: <http://schema.org/>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    
    SELECT DISTINCT ?label
    WHERE {
        ?s a rdf:Property ;
            rdfs:label ?label .
    }

Some Properties are using a list syntax, like this.

schema:position a rdf:Property ;
    schema:domainIncludes schema:CreativeWork,
        schema:ListItem ;

Which, as far as i ahve understood is equivalent to

schema:position a rdf:Property ;
        schema:domainIncludes schema:CreativeWork ;
        schema:domainIncludes schema:ListItem .

So i dont understand what is going wrong. is it the library or something else?


Solution

  • schema.org uses https, and correct prefix is https://schema.org/ instead of http://schema.org/ Another issue is that query is matching with string literal instead of iri which is why it's not filtering as intended. Iri notation should be used like schema:ListItem, or http://schema.org/ListItem, instead of string literal "".