将对象链接到RDF域中的主题

时间:2014-06-06 14:38:36

标签: rdf semantic-web static-linking owl rdfs

我有这个RDF文件:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:j.0="http://relation/"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> 
  <rdf:Description rdf:about="soggetto">
    <j.0:Nome>Vercelli</j.0:Nome>
    <j.0:Regione>Piemonte</j.0:Regione>
  </rdf:Description>
  <rdf:Description rdf:about="Piemonte">
    <rdfs:label>Piemonte</rdfs:label>
  </rdf:Description>
  <rdf:Description rdf:about="Regione">
    <rdfs:label>Regione</rdfs:label>
    <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
  </rdf:Description>
  <rdf:Description rdf:about="Vercelli">
    <rdfs:label>Vercelli</rdfs:label>
  </rdf:Description>
  <rdf:Description rdf:about="Nome">
    <rdfs:label>Nome</rdfs:label>
    <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
  </rdf:Description>
</rdf:RDF>

我想将Piemonte和Vercelli对象(在“soggetto”主题中)与Piemonte和Vercelli主题联系起来,我想将Regione和Nome谓词(在“soggetto”主题中)与Regione和Nome主题联系起来。

对我来说,Vercelli主语等于Vercelli对象,Piemonte主语等于Piemonte对象,Regione谓词等于Regione主语,Nome谓词等于Nome主语。

我怎么能做到这一点? 我可以使用rdf:type谓词来使Vercelli对象等同于Vercelli主题吗? 或者是否存在其他属性?

1 个答案:

答案 0 :(得分:1)

认为你真正想要的是如何将资源用作某些主题的对象,而不是恰好具有类似内容的字符串。首先,让我们为您的数据添加xml:basexmlns,以便更加可预测:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:j.0="http://stackoverflow.com/q/24084473/1281433/relations/"
    xml:base="http://stackoverflow.com/q/24084473/1281433/"
    xmlns="http://stackoverflow.com/q/24084473/1281433/"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> 
  <rdf:Description rdf:about="soggetto">
    <j.0:Nome>Vercelli</j.0:Nome>
    <j.0:Regione>Piemonte</j.0:Regione>
  </rdf:Description>
  <rdf:Description rdf:about="Piemonte">
    <rdfs:label>Piemonte</rdfs:label>
  </rdf:Description>
  <rdf:Description rdf:about="Regione">
    <rdfs:label>Regione</rdfs:label>
    <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
  </rdf:Description>
  <rdf:Description rdf:about="Vercelli">
    <rdfs:label>Vercelli</rdfs:label>
  </rdf:Description>
  <rdf:Description rdf:about="Nome">
    <rdfs:label>Nome</rdfs:label>
    <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
  </rdf:Description>
</rdf:RDF>

现在,使用Turtle / N3序列化比使用RDF / XML更容易,所以让我们看看Turtle中的相同数据:

@prefix :      <http://stackoverflow.com/q/24084473/1281433/> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix j.0:   <http://stackoverflow.com/q/24084473/1281433/relations/> .

:Nome   a           rdf:Property ;
        rdfs:label  "Nome" .

:Regione  a         rdf:Property ;
        rdfs:label  "Regione" .

:Vercelli  rdfs:label  "Vercelli" .

:soggetto  j.0:Nome  "Vercelli" ;
        j.0:Regione  "Piemonte" .

:Piemonte  rdfs:label  "Piemonte" .

更容易看到数据结构,并了解如何解决这个问题。这听起来不是说

:soggetto  j.0:Nome  "Vercelli" ;
        j.0:Regione  "Piemonte" .

您希望将:soggetto的区域设为资源:Piemonte,您只需使用:Piemonte代替"Piemonte"即可。然后你的数据,在Turtle和RDF / XML中将是

@prefix :      <http://stackoverflow.com/q/24084473/1281433/> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix j.0:   <http://stackoverflow.com/q/24084473/1281433/relations/> .

:Nome   a           rdf:Property ;
        rdfs:label  "Nome" .

:Regione  a         rdf:Property ;
        rdfs:label  "Regione" .

:Vercelli  rdfs:label  "Vercelli" .

:soggetto  j.0:Nome  "Vercelli" ;
        j.0:Regione  :Piemonte .

:Piemonte  rdfs:label  "Piemonte" .
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://stackoverflow.com/q/24084473/1281433/"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:j.0="http://stackoverflow.com/q/24084473/1281433/relations/">
  <rdf:Property rdf:about="http://stackoverflow.com/q/24084473/1281433/Regione">
    <rdfs:label>Regione</rdfs:label>
  </rdf:Property>
  <rdf:Property rdf:about="http://stackoverflow.com/q/24084473/1281433/Nome">
    <rdfs:label>Nome</rdfs:label>
  </rdf:Property>
  <rdf:Description rdf:about="http://stackoverflow.com/q/24084473/1281433/soggetto">
    <j.0:Nome>Vercelli</j.0:Nome>
    <j.0:Regione>
      <rdf:Description rdf:about="http://stackoverflow.com/q/24084473/1281433/Piemonte">
        <rdfs:label>Piemonte</rdfs:label>
      </rdf:Description>
    </j.0:Regione>
  </rdf:Description>
  <rdf:Description rdf:about="http://stackoverflow.com/q/24084473/1281433/Vercelli">
    <rdfs:label>Vercelli</rdfs:label>
  </rdf:Description>
</rdf:RDF>