我並不完全清楚你想在這裏模擬的東西;用戶資源具有三位整數值,或者X和Y資源具有整數值。我會假設後者,因爲它更復雜。
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://example.org/ns#">
<User rdf:about="#T">
<hasName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">T</hasName>
<hasFavourite rdf:resource="#x"/>
<hasFavourite rdf:resource="#y"/>
</User>
<hasFavourite rdf:about="#x">
<integerThatMeansSomething rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">10</integerThatMeansSomething>
</hasFavourite>
<hasFavourite rdf:about="#y">
<integerThatMeansSomething rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">20</integerThatMeansSomething>
</hasFavourite>
</rdf:RDF>
這是稍微容易在龜閱讀:(通過rapper -q -o turtle foo.rdf 'http://example.org/ns#'
從我Raptor軟件轉換)
@base <http://example.org/ns#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <> .
:T
:hasFavourite :x, :y ;
:hasName "T"^^<http://www.w3.org/2001/XMLSchema#string> ;
a :User .
:x
:integerThatMeansSomething 10 ;
a :hasFavourite .
:y
:integerThatMeansSomething 20 ;
a :hasFavourite .
聲明:我編輯的RDF/XML,發明了烏龜並寫下上面的軟件!
上面的讀法是這樣的:「T是一個用戶,有兩個最喜歡的x和y以及一個字符串名稱,X是一個最喜歡的值,它的整數屬性值爲10。爲Y.
等。如果是前者,RDF/XML是簡單的:
<User rdf:about="#T">
<hasName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">T</hasName>
<hasFavourite rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">10</hasFavourite>
<hasFavourite rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">20</hasFavourite>
</User>
鑑於對問題的澄清,這對我來說似乎是正確的數據模型。有時候在紙上繪製這個更容易,但是在網頁上寫下來很難! – dajobe 2009-12-09 17:14:01
絕對容易在紙上寫下來,儘管對於網絡而言,我寧願在任何一天在Turtle中輸入它,而不是RDF/XML – RobV 2009-12-10 10:42:59
Cheers guys。我剛開始嘗試它,它的工作原理。我沒有考慮創建一個基本上是關係的類型! 再次感謝 – allyLogan 2009-12-10 20:26:27