RDF 主要元素
- หน้าก่อนหน้า ตัวอย่าง RDF
- หน้าต่อไป ตัวจัดเก็บ RDF
RDF 的主要元素是 <RDF> 以及可表示某個資源的 <Description> 元素。
<rdf:RDF> 元素
<rdf:RDF> 是 RDF 文档的根元素。它把 XML 文档定義為一個 RDF 文档。它也包含對 RDF 命名空間的引用:
<?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> . . Description goes here . </rdf:RDF>
<rdf:Description> 元素
<rdf:Description> 元素可通過 about 屬性標識一個資源。
<rdf:Description> 元素可包含描述資源的這些元素:
<?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/Empire Burlesque"> <cd:artist>Bob Dylan</cd:artist> <cd:country>USA</cd:country> <cd:company>Columbia</cd:company> <cd:price>10.90</cd:price> <cd:year>1985</cd:year> </rdf:Description> </rdf:RDF>
artist、country、company、price 以及 year 這些元素被定義在命名空間 http://www.recshop.fake/cd# 中。此命名空間在 RDF 之外(並非 RDF 的組成部分)。RDF 仅仅定義了這個框架。而 artist、country、company、price 以及 year 這些元素必須被其他人(公司、組織或個人等)進行定義。
属性(property)來定義屬性(attribute)
ตัวแปรองค์ประกอบ (property elements) ก็สามารถถูกกำหนดเป็นตัวแปร (attributes) ได้ (ทดแทนองค์ประกอบ):
<?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/Empire Burlesque" cd:artist="Bob Dylan" cd:country="USA" cd:company="Columbia" cd:price="10.90" cd:year="1985" /> </rdf:RDF>
กำหนดทรัพยากร
ตัวแปรองค์ประกอบ (property elements) ก็สามารถถูกกำหนดเป็นทรัพยากร (resources) ได้:
ในตัวอย่างด้านบน คุณภาพจากตัวแปร artist ไม่มีค่า แต่อ้างอิงถึงทรัพยากรที่มีข้อมูลเกี่ยวกับนักแสดง
<?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/Empire Burlesque"> <cd:artist rdf:resource="http://www.recshop.fake/cd/dylan" /> . . . . </rdf:Description> </rdf:RDF>
- หน้าก่อนหน้า ตัวอย่าง RDF
- หน้าต่อไป ตัวจัดเก็บ RDF