title: How to query DBpedia SPARQL by resource uri?
body: <p>I'm querying DBpedia types in SPARQL (<a href="http://dbpedia.org/sparql" rel="nofollow">http://dbpedia.org/sparql</a>) by resource's label</p>
  
  <pre><code>PREFIX owl: &lt;http://www.w3.org/2002/07/owl#&gt;
  PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;
  PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
  PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
  PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
  PREFIX dc: &lt;http://purl.org/dc/elements/1.1/&gt;
  PREFIX skos: &lt;http://www.w3.org/2004/02/skos/core#&gt;
  PREFIX : &lt;http://dbpedia.org/resource/&gt;
  PREFIX ru: &lt;http://ru.dbpedia.org/resource/&gt;
  PREFIX dbpedia2: &lt;http://dbpedia.org/property/&gt;
  PREFIX dbpedia: &lt;http://dbpedia.org/&gt;
  PREFIX dbo: &lt;http://dbpedia.org/ontology/&gt;
  
  SELECT ?type ?superType WHERE { {
    ?res rdfs:label "HarryPotter"@en.
  } UNION {
    ?redir dbo:wikiPageRedirects ?res .
    ?redir rdfs:label "HarryPotter"@en .
  }
  ?res rdf:type ?type .
  OPTIONAL {
    ?type rdfs:subClassOf ?superType .
  }
  }
  </code></pre>
  
  <p><a href="http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&amp;query=PREFIX+owl%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2002%2F07%2Fowl%23%3E%0D%0APREFIX+xsd%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%3E%0D%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0D%0APREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0D%0APREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0D%0APREFIX+dc%3A+%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%0D%0APREFIX+skos%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2004%2F02%2Fskos%2Fcore%23%3E%0D%0APREFIX+%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2F%3E%0D%0APREFIX+ru%3A+%3Chttp%3A%2F%2Fru.dbpedia.org%2Fresource%2F%3E%0D%0APREFIX+dbpedia2%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2F%3E%0D%0APREFIX+dbpedia%3A+%3Chttp%3A%2F%2Fdbpedia.org%2F%3E%0D%0APREFIX+dbo%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fontology%2F%3E%0D%0ASELECT+%3Ftype+%3FsuperType+WHERE+%7B+%7B%0D%0A++%3Fres+rdfs%3Alabel+%22HarryPotter%22%40en.%0D%0A%7D+UNION+%7B%0D%0A++%3Fredir+dbo%3AwikiPageRedirects+%3Fres+.%0D%0A++%3Fredir+rdfs%3Alabel+%22HarryPotter%22%40en+.%0D%0A%7D%0D%0A%3Fres+rdf%3Atype+%3Ftype+.%0D%0AOPTIONAL+%7B%0D%0A++%3Ftype+rdfs%3AsubClassOf+%3FsuperType+.%0D%0A%7D%0D%0A+%7D&amp;format=text%2Fhtml&amp;CXML_redir_for_subjs=121&amp;CXML_redir_for_hrefs=&amp;timeout=30000&amp;debug=on" rel="nofollow">It works fine</a>.</p>
  
  <p>But what if I know the exact resource - <a href="http://dbpedia.org/page/Harry_Potter" rel="nofollow">http://dbpedia.org/page/Harry_Potter</a>? I tried something like:</p>
  
  <pre><code>?res a :Harry_Potter.
  </code></pre>
  
  <p>But it does not work.</p>
  
  <p>How to query DBpedia types and supertypes if I know the resource URI? I can't figure out which property or operator I should use (e.g., <code>rdfs:Resource</code>, <code>a</code>, etc., which do not work)</p>