简体   繁体   中英

New to Protege and Sparql

I am trying to learn ontologies and Sparql using Protege... I'm trying to figure out Sparql code to show subClasses of a given class:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>               
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX untitled-ontology-10: <http://www.semanticweb.org/chris/ontologies/2022/8/untitled-ontology-10#>

SELECT DISTINCT ?subclass 
WHERE {
  ?subclass rdfs:subClassOf Class.Thing  .
} 

In the example here I'm trying to find all subclasses of the class Thing (or of any other defined class, eg Professions, in my project). "Class.Thing" doesn't work of course. Neither does:Thing nor ns:Thing nor #Thing nor any of the other variants I've found in examples. Of course if I use a variable in place of "Class.Thing", it'll show me ALL classes, but I would really like to narrow it down to subclasses of a specific class. Can anyone tell me how to do this?

You have to provide the URI of the class.

Either as an absolute URI:

?subclass rdfs:subClassOf <http://www.semanticweb.org/chris/ontologies/2022/8/untitled-ontology-10#Thing> .

Or as a prefixed name (like rdfs:subClassOf ):

?subclass rdfs:subClassOf untitled-ontology-10:Thing .

(You can change the URI of your ontology in Protégé. If you intend to publish your ontology and/or data, you should use a URI namespace under your control, eg, under your own domain name.)

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