简体   繁体   中英

Sparql Query to retrieve all the properties and classes belong to specific class

I have ontology URI and I need to know all the properties and classes belongs to this ontology. the URI of the ontology Prefix Names: http://data.Ordanancesurvery.cor.uk/ontology/OpenName# . It is hosted by ordnance survey and The API is: https://data.ordnancesurvey.co.uk/datasets/os-linked-data/explorer/sparql I need Sparql query which can retrieve all the classes and properties from the ontology.


 PREFIX Names: <http://data.ordnancesurvey.co.uk/ontology/OpenNames/> 
 PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
    PREFIX owl:<http://www.w3.org/2002/07/owl#>

      SELECT  ?s ?p ?o

       WHERE {
        ?s ?p ?o

 Filter (regex (?o,"OpenNames")) 

  }

I am trying to retrieve all the classes and properties, belong to the ontology OpenNames under the uri: http://data.ordnancesurvey.co.uk/ontology/OpenNames/

URIs are not strings. Conversion is not automatic. Use str(?o)

regex (str(?o),"OpenNames") or CONTAINS(str(?o),"OpenNames")

Better is

STRSTARTS(str(?o), str(Names:))

Prefixes are expanded during parsing so

str(Names:)

is the same as writing

str(<http://data.ordnancesurvey.co.uk/ontology/OpenNames/>)

then STRSTARTS does a leading string test.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM