为什么我在尝试在FOAF上使用关系时发生错误?

问题描述:

我想验证W3C RDF上的foaf代码,并从下面的块中引发问题。在这里,我试图展示兰迪和阿迪尔之间的关系,请原谅我为什么我不能在这里使用“rel”标签或为什么它会导致问题?为什么我在尝试在FOAF上使用关系时发生错误?

<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] 
+0

考虑要求对answers.semanticweb.com – harschware 2011-05-06 20:25:55

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

<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/"> 
+0

如果我需要出示相关,如“爱”,“喜欢”和等等? – Himalay 2011-05-06 14:11:23

+0

@Himalay:'rel'中似乎没有这种关系。你可以定义你自己的关系,也许作为http://www.perceive.net/schemas/20031015/relationship/relationship.rdf的子属性,但是你的文件可能不适用于FOAF API。 – 2011-05-06 14:13:45

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

这个例子应该为你工作...

<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:[email protected]"/> 
    <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:workplaceHomepagerel:friendOf没有太大的意义。您也可以在这里使用foaf:knows