2011-05-06 61 views
4

我想驗證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

回答

3

你應該包裝在聲明適當的命名空間的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

3

您需要聲明的命名空間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

相關問題