====== SPARQL Tutorial ====== * https://stackoverflow.com/questions/18458150/how-to-query-classes-with-object-property-in-sparql * http://ncorwiki.buffalo.edu/index.php/Introduction_to_Prot%C3%A9g%C3%A9 ====== Headline ====== PREFIX rdf: PREFIX owl: PREFIX rdfs: PREFIX xsd: prefix omn: prefix omn-resource: prefix omn-domain-nfv: prefix omn-lifecycle: prefix time: prefix isco: SELECT ?subject ?object WHERE { ?subject rdf:SubClass omn-domain-nfv:Parameter } SELECT ?subject ?object WHERE { ?subject rdfs:subClassOf ?object } ===== - Return Instances ===== ?s rdf:type omn:Service . ===== - Return subclasses, recursive subclasses ===== SELECT ?s WHERE { ?s rdfs:subClassOf* omn:Service . } ?s rdfs:subClassOf* omn:Service . ===== - etc ===== SELECT ?subject ?object WHERE { ?subject a omn-lifecycle:State } SELECT ?domain ?range WHERE { omn-resource:hasInterface rdfs:domain ?domain ; rdfs:range ?range . } ===== - isco example ===== PREFIX rdf: PREFIX owl: PREFIX rdfs: PREFIX xsd: prefix omn: prefix omn-resource: prefix omn-domain-nfv: prefix omn-lifecycle: prefix time: prefix isco: SELECT ?subject ?object WHERE { ?subject omn:hasReservation isco:life3} ===== - find subject with value ===== PREFIX rdf: PREFIX owl: PREFIX rdfs: PREFIX xsd: SELECT ?subject ?object WHERE { ?subject ?p ?o . filter( str(?o) = "60" ) } ===== - Search class by label (must be manually defined) ===== PREFIX rdf: PREFIX owl: PREFIX rdfs: PREFIX xsd: prefix omn: prefix omn-resource: prefix omn-domain-nfv: prefix omn-lifecycle: prefix time: prefix policy: SELECT ?s ?p ?o ?classLabel WHERE { ?s rdfs:subClassOf* policy:QosClass . ?s ?p ?o . ?s rdfs:label ?classLabel . FILTER regex(?classLabel, "Class0", "i") SELECT ?g ?s ?p ?o ?about WHERE { ?s rdfs:range omn:Resource . ?s ?p ?o . FILTER regex(str(?p), "type", "i") } ===== - Sparql function ===== ==== - Regex ==== * https://www.w3.org/TR/sparql11-query/#func-strings PREFIX foaf: SELECT ?name WHERE { ?x foaf:name ?name FILTER regex(?name, "^ali", "i") } ====== Protege Bug ====== * SPARQL view (not tab) must be close/reopen when new ontology file is loaded. It looks like data from previous ontology is still loaded. Also check "Files --> Loaded ontology sources"