我不完全清楚你想在这里建模什么;用户资源具有整数值的三元组或 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>
这在 Turtle 中更容易阅读:(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,发明了 Turtle 并编写了上面的软件!
上面的读法如下:“T 是一个用户,有两个收藏夹 x 和 y 以及一个字符串名称。X 是收藏夹,并且有一个值为 10 的整数属性。” 等等。
如果是前者,则 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>