2016-07-15 49 views
1

我正在學習如何與JSON-LD一起工作,並且我被困在這個問題上。這是我的文檔...JSON-LD的錯誤擴展

{ 
"@context": { 
    "dbr": "http://dbpedia.org/resource/", 
    "xsd": "http://www.w3.org/2001/XMLSchema#", 
    "italy": "dbr:Italy_national_football_team", 
    "ita_player_base_url": "italy:/", 
    "foaf": "http://xmlns.com/foaf/0.1/", 
    "team": "foaf:Organization", 
    "player": "foaf:Person", 
    "player_of": { 
     "@id": "foaf:member", 
     "@type": "@id" 
    }, 
    "plays_with": { 
     "@id": "foaf:knows", 
     "@type": "@id" 
    }, 
    "name": { 
     "@id": "foaf:name", 
     "@type": "xsd:string" 
    }, 
    "number": { 
     "@id": "foaf:status", 
     "@type": "xsd:positiveInteger" 
    } 
}, 
"@graph": [{ 
    "name": "Buffon", 
    "number": "1", 
    "@type": "player", 
    "player_of": "italy", 
    "@id": "ita_player_base_url:Buffon" 
}, { 
    "name": "Insigne", 
    "number": "20", 
    "@type": "player", 
    "player_of": "italy", 
    "@id": "ita_player_base_url:Insigne", 
    "plays_with": "ita_player_base_url:Buffon" 
}]} 

然後,如果我把它粘貼到一個JSON-LD爲GIF服務(或一切),我得到了球員們的"player_of":"domainOfTheValidator/italy"代替"player_of":"http://dbpedia.org/resource/Italy_national_football_team" 這究竟是爲什麼?很明顯,如果我把"player_of": "dbr:Italy_national_football_team"而不是"player_of": "italy"它的作品...我越來越瘋狂。

回答

0

A compact IRI由前綴,後跟:,後跟後綴組成。

使用"italy": "dbr:Italy_national_football_team"您正在定義前綴(italy)。當你想在一個值中使用它時,你必須使用冒號(:)後跟一個後綴(在你的情況下爲空)。

所以不是

"player_of": "italy", 

,你將不得不使用

"player_of": "italy:", 
+0

旁註:你知道,例如'http:// dbpedia.org/resource/Italy_national_football_team/Buffon'不存在?你可能是指'http:// dbpedia.org/resource/Gianluigi_Buffon'。 – unor

+0

是的,現在我明白了!非常感謝你,你做了我的一天! – Riccardo