4

我正在尝试验证W3C RDF上的 foaf 代码以及它导致问题的下一个块。在这里,我试图展示 Randy 和 Adil 之间的关系,请纠正我为什么我不能在这里使用“rel”标签或者为什么会导致问题?

<foaf:knows>
        <foaf:Person>

        <foaf:name>Randy</foaf:name>

        <foaf:mbox_sha1sum>0525a7bfaf263d404e751bb12b89e4acc1ce68a7</foaf:mbox_sha1sum>
        <rdfs:workplaceHomepage rdf:resource="randy.html" />
    <rel:friendOf rdf:resource="adil.html"/>        
  </foaf:Person>
    </foaf:knows>

错误:

FatalError: The prefix "rel" for element "rel:friendOf" is not bound.[Line = 39, Column = 46]
4

2 回答 2

3

您需要以rel您必须foaf在 RDF/XML 文档顶部指定的相同方式声明名称空间。

这个例子应该适合你......

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:rel="http://some.namespace.for.rel.com/ns/"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
         >
 <foaf:Person>
   <foaf:name>Peter Parker</foaf:name>
   <foaf:mbox rdf:resource="mailto:peter.parker@dailybugle.com"/>
    <foaf:knows>
        <foaf:Person>
        <foaf:name>Randy</foaf:name>
        <foaf:mbox_sha1sum>0525a7bfaf263d404e751bb12b89e4acc1ce68a7</foaf:mbox_sha1sum>
        <rdfs:workplaceHomepage rdf:resource="randy.html" />
    <rel:friendOf rdf:resource="adil.html"/>        
      </foaf:Person>
    </foaf:knows>
 </foaf:Person>
</rdf:RDF>

无论如何,您的使用rdfs:workplaceHomepage是错误的,您应该使用foaf:workplaceHomepage并且rel:friendOf没有多大意义。你也可以foaf:knows在这里使用。

于 2011-05-06T13:55:18.477 回答
3

您应该将 FOAF 内容包装在RDF声明适当命名空间的元素中:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:foaf="http://xmlns.com/foaf/0.1/"
     xmlns:rel="http://www.perceive.net/schemas/relationship/">
于 2011-05-06T13:57:47.890 回答