Latest web development tutorials

RDF 容器

RDF容器用於描述一組事物。 舉個例子,把某本書的作者列在一起。

下面的RDF元素用於描述這些的組:<Bag>、<Seq>以及<Alt>。


h2><rdf:Bag> 元素

<rdf:Bag> 元素用於描述一個規定為無序的值的列表。

<rdf:Bag> 元素可包含重複的值。

實例

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Beatles">
<cd:artist>
<rdf:Bag>
<rdf:li>John</rdf:li>
<rdf:li>Paul</rdf:li>
<rdf:li>George</rdf:li>
<rdf:li>Ringo</rdf:li>
</rdf:Bag>
</cd:artist>
</rdf:Description>

</rdf:RDF>


<rdf:Seq> 元素

<rdf:Seq> 元素用於描述一個規定為有序的值的列表(比如一個字母順序的排序)。

<rdf:Bag> 元素可包含重複的值。

實例

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Beatles">
<cd:artist>
<rdf:Seq>
<rdf:li>George</rdf:li>
<rdf:li>John</rdf:li>
<rdf:li>Paul</rdf:li>
<rdf:li>Ringo</rdf:li>
</rdf:Seq>
</cd:artist>
</rdf:Description>

</rdf:RDF>


<rdf:Alt> 元素

<rdf:Alt> 元素用於一個可替換的值的列表(用戶僅可選擇這些值的其中之一)。

實例

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Descriptio
rdf:about="http://www.recshop.fake/cd/Beatles">
<cd:format>
<rdf:Alt>
<rdf:li>CD</rdf:li>
<rdf:li>Record</rdf:li>
<rdf:li>Tape</rdf:li>
</rdf:Alt>
</cd:format>
</rdf:Descriptio>

</rdf:RDF>


RDF 術語

在上面的例子中,我們在描述容器元素時已經討論了"值的列表"。 在RDF 中,這些"值的列表"被稱為成員(members)。

因此,我們可以這麼說:

  • 一個容器是一個包含事物的資源
  • 被包含的事物被稱為成員(不能稱為"值的列表")。