2014-10-30 47 views
0

我想查詢所有關於班級/個人的AnnotationAssertion。查詢某個班級/個人的所有「AnnotationAssertion」

下面是我的源代碼片段:

 <AnnotationAssertion> 
      <AnnotationProperty abbreviatedIRI="rdfs:comment"/> 
      <IRI>#Car</IRI> 
      <Literal xml:lang="en" datatypeIRI="&rdf;PlainLiteral">A car has four tyres</Literal> 
     </AnnotationAssertion> 
     <AnnotationAssertion> 
      <AnnotationProperty IRI="http://www.w3.org/2004/02/skos/core#definition"/> 
      <IRI>#car</IRI> 
      <Literal xml:lang="en" datatypeIRI="&rdf;PlainLiteral">a road vehicle, typically with four wheels, powered by an internal combustion engine and able to carry a small number of people.</Literal> 
     </AnnotationAssertion> 
     <AnnotationAssertion> 
      <AnnotationProperty IRI="http://www.w3.org/2004/02/skos/core#example"/> 
      <IRI>#car</IRI> 
      <Literal xml:lang="en" datatypeIRI="&rdf;PlainLiteral">Audi</Literal> 
     </AnnotationAssertion> 
etc.. 

我試圖查詢這個類/個人及其AnnotationAssertions的列表相關AnnotationProperties。

SPARQL-DL API提供了可能性,通過

Annotation(a, b, c) 

查詢annotationproperties對查詢AnnotationAssertions任何指針將是很有益的。

+0

您是否試圖用SPARQL-DL或簡單的SPARQL做到這一點? – 2014-10-30 15:13:56

+0

我開始使用SPARQL-DL,但是如果使用普通的SPARQL,它可能會很好。 – Betafish 2014-10-30 15:17:52

+0

好的,我想我的答案顯示了在普通SPARQL中執行此操作的方法。 – 2014-10-30 15:18:33

回答

2

您在提問中提到了SPARQL-DL,但它也被標記爲,並且普通SPARQL中的答案並不太複雜。這將是沿着線的東西:

prefix owl: <http://www.w3.org/2002/07/owl#> 

select ?s ?p ?o where { 
    ?s ?p ?o . 
    ?p a owl:AnnotationProperty . 
} 

,你可能會遇到在這裏的困難,不過,是它可能不是每個註釋屬性實際上宣佈此案。這會讓事情變得更加困難,但可以通過詢問除了屬性是已知的ObjectProperty或DatatypeProperty之外的所有三元組以及OWL到RDF映射中使用的那些元素(以rdf開頭的屬性:或貓頭鷹:和某些rdfs:屬性)。例如,

prefix owl: <http://www.w3.org/2002/07/owl#> 
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> 

select ?s ?p ?o where { 
    ?s ?p ?o . 

    #-- don't include object or datatype properties  
    filter not exists { 
    values ?type { owl:ObjectProperty owl:DatatypeProperty } 
    ?p a ?type 
    } 

    #-- don't include properties from rdf: or owl: namespaces 
    filter(!strstarts(str(?p), str(rdf:))) 
    filter(!strstarts(str(?p), str(owl:))) 

    #-- don't include rdfs: properties used in OWL to RDF mapping 
    filter(?p not in (rdfs:range, rdfs:domain, rdfs:subClassOf, rdfs:subPropertyOf)) 
} 
相關問題