XML RDF
Contoh Dokumen RDF
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:si="https://www.w3schools.com/rdf/">
<rdf:Description rdf:about="https://www.w3schools.com">
<si:title>W3Schools</si:title>
<si:author>Jan Egil Refsnes</si:author>
</rdf:Description>
</rdf:RDF>
Apa itu RDF?
- RDF adalah singkatan dari R esource D escription F ramework
- RDF adalah kerangka kerja untuk menggambarkan sumber daya di web
- RDF dirancang untuk dibaca dan dipahami oleh komputer
- RDF tidak dirancang untuk ditampilkan kepada orang-orang
- RDF ditulis dalam XML
- RDF adalah bagian dari Aktivitas Web Semantik W3C
- RDF adalah Rekomendasi W3C dari 10. Februari 2004
RDF - Contoh Penggunaan
- Menjelaskan properti untuk item belanja, seperti harga dan ketersediaan
- Menjelaskan jadwal waktu untuk acara web
- Menjelaskan informasi tentang halaman web (konten, penulis, tanggal dibuat dan diubah)
- Menjelaskan konten dan peringkat untuk gambar web
- Menjelaskan konten untuk mesin pencari
- Menjelaskan perpustakaan elektronik
RDF Dirancang untuk Dibaca oleh Komputer
RDF dirancang untuk menyediakan cara umum untuk menggambarkan informasi sehingga dapat dibaca dan dipahami oleh aplikasi komputer.
Deskripsi RDF tidak dirancang untuk ditampilkan di web.
RDF Ditulis dalam XML
Dokumen RDF ditulis dalam XML. Bahasa XML yang digunakan oleh RDF disebut RDF/XML.
Dengan menggunakan XML, informasi RDF dapat dengan mudah dipertukarkan antara berbagai jenis komputer menggunakan berbagai jenis sistem operasi dan bahasa aplikasi.
RDF dan "Web Semantik"
Bahasa RDF adalah bagian dari Aktivitas Web Semantik W3C. "Visi Web Semantik" W3C adalah masa depan di mana:
- Informasi web memiliki arti yang tepat
- Informasi web dapat dipahami dan diproses oleh komputer
- Komputer dapat mengintegrasikan informasi dari web
RDF menggunakan pengidentifikasi Web (URI) untuk mengidentifikasi sumber daya.
RDF menjelaskan sumber daya dengan properti dan nilai properti.
Sumber Daya, Properti, dan Nilai Properti RDF
RDF mengidentifikasi berbagai hal menggunakan pengidentifikasi Web (URI), dan menjelaskan sumber daya dengan properti dan nilai properti.
Penjelasan tentang Resource, Property, dan Property value:
- Resource adalah segala sesuatu yang dapat memiliki URI, seperti "https://www.w3schools.com/rdf"
- Properti adalah Sumber Daya yang memiliki nama , seperti "penulis" atau "beranda"
- Nilai Properti adalah nilai Properti, seperti "Jan Egil Refsnes" atau "https://www.w3schools.com" (perhatikan bahwa nilai properti dapat berupa sumber daya lain)
Dokumen RDF berikut dapat menjelaskan sumber daya "https://www.w3schools.com/rdf":
<?xml version="1.0"?>
<RDF>
<Description about="https://www.w3schools.com/rdf">
<author>Jan Egil Refsnes</author>
<homepage>https://www.w3schools.com</homepage>
</Description>
</RDF>
Contoh di atas disederhanakan. Namespace dihilangkan.
Pernyataan RDF
Kombinasi nilai Resource, Property, dan Property membentuk Statement (dikenal sebagai subjek, predikat, dan objek dari Statement).
Mari kita lihat beberapa contoh pernyataan untuk mendapatkan pemahaman yang lebih baik:
Pernyataan: "Penulis https://www.w3schools.com/rdf adalah Jan Egil Refsnes".
- Subjek pernyataan di atas adalah: https://www.w3schools.com/rdf
- Predikatnya adalah: pengarang
- Objeknya adalah: Jan Egil Refsnes
Pernyataan: "Beranda https://www.w3schools.com/rdf adalah https://www.w3schools.com".
- Subjek pernyataan di atas adalah: https://www.w3schools.com/rdf
- Predikatnya adalah: beranda
- Objeknya adalah: https://www.w3schools.com
Contoh RDF
Berikut adalah dua catatan dari daftar CD:
Title | Artist | Country | Company | Price | Year |
---|---|---|---|---|---|
Empire Burlesque | Bob Dylan | USA | Columbia | 10.90 | 1985 |
Hide your heart | Bonnie Tyler | UK | CBS Records | 9.90 | 1988 |
Di bawah ini adalah beberapa baris dari dokumen RDF:
<?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:Description
rdf:about="http://www.recshop.fake/cd/Hide your heart">
<cd:artist>Bonnie Tyler</cd:artist>
<cd:country>UK</cd:country>
<cd:company>CBS Records</cd:company>
<cd:price>9.90</cd:price>
<cd:year>1988</cd:year>
</rdf:Description>
.
.
.
</rdf:RDF>
Baris pertama dari dokumen RDF adalah deklarasi XML. Deklarasi XML diikuti oleh elemen root dari dokumen RDF: <rdf:RDF> .
Ruang nama xmlns:rdf , menetapkan bahwa elemen dengan awalan rdf berasal dari ruang nama "http://www.w3.org/1999/02/22-rdf-syntax-ns#".
Ruang nama xmlns:cd , menetapkan bahwa elemen dengan awalan cd berasal dari ruang nama "http://www.recshop.fake/cd#".
Elemen <rdf:Description> berisi deskripsi sumber daya yang diidentifikasi oleh atribut rdf:about .
Elemen: <cd:artist>, <cd:country>, <cd:company>, dll. adalah properti dari resource.
Validator Online RDF
Layanan Validasi RDF W3C berguna saat mempelajari RDF. Di sini Anda dapat bereksperimen dengan file RDF.
Validator RDF online mem-parsing dokumen RDF Anda, memeriksa sintaks Anda, dan menghasilkan tampilan tabular dan grafis dari dokumen RDF Anda.
Salin dan tempel contoh di bawah ini ke validator RDF W3C:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:si="https://www.w3schools.com/rdf/">
<rdf:Description rdf:about="https://www.w3schools.com">
<si:title>W3Schools.com</si:title>
<si:author>Jan Egil Refsnes</si:author>
</rdf:Description>
</rdf:RDF>
Saat Anda mengurai contoh di atas, hasilnya akan terlihat seperti ini .
Elemen RDF
Elemen utama RDF adalah elemen root, <RDF>, dan elemen <Description>, yang mengidentifikasi sumber daya.
Elemen <rdf:RDF>
<rdf:RDF> adalah elemen root dari dokumen RDF. Ini mendefinisikan dokumen XML menjadi dokumen RDF. Itu juga berisi referensi ke namespace RDF:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
...Description goes here...
</rdf:RDF>
Elemen <rdf:Deskripsi>
Elemen <rdf:Description> mengidentifikasi sumber daya dengan atribut about.
Elemen <rdf:Description> berisi elemen yang menjelaskan sumber daya:
<?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>
Elemen, artis, negara, perusahaan, harga, dan tahun, ditentukan dalam ruang nama http://www.recshop.fake/cd#. Namespace ini berada di luar RDF (dan bukan bagian dari RDF). RDF hanya mendefinisikan kerangka kerja. Elemen, artis, negara, perusahaan, harga, dan tahun, harus ditentukan oleh orang lain (perusahaan, organisasi, orang, dll).
Properti sebagai Atribut
Elemen properti juga dapat didefinisikan sebagai atribut (bukan elemen):
<?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>
Properti sebagai Sumber Daya
Elemen properti juga dapat didefinisikan sebagai sumber daya:
<?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>
Dalam contoh di atas, artis properti tidak memiliki nilai, tetapi referensi ke sumber daya yang berisi informasi tentang artis.
Kontainer RDF
Wadah RDF digunakan untuk menggambarkan sekelompok hal.
Elemen RDF berikut digunakan untuk mendeskripsikan grup: <Bag>, <Seq>, dan <Alt>.
Elemen <rdf:Tas>
Elemen <rdf:Bag> digunakan untuk menjelaskan daftar nilai yang tidak harus dalam urutan tertentu.
Elemen <rdf:Bag> mungkin berisi nilai duplikat.
Contoh
<?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>
Elemen <rdf:Seq>
Elemen <rdf:Seq> digunakan untuk mendeskripsikan daftar nilai yang diurutkan (Misalnya, dalam urutan abjad).
Elemen <rdf:Seq> mungkin berisi nilai duplikat.
Contoh
<?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>
Elemen <rdf:Alt>
Elemen <rdf:Alt> digunakan untuk menjelaskan daftar nilai alternatif (pengguna hanya dapat memilih salah satu nilai).
Contoh
<?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:format>
<rdf:Alt>
<rdf:li>CD</rdf:li>
<rdf:li>Record</rdf:li>
<rdf:li>Tape</rdf:li>
</rdf:Alt>
</cd:format>
</rdf:Description>
</rdf:RDF>
Ketentuan RDF
Dalam contoh di atas kita telah berbicara tentang "daftar nilai" saat menjelaskan elemen penampung. Dalam RDF "daftar nilai" ini disebut anggota.
Jadi, kami memiliki yang berikut:
- Wadah adalah sumber daya yang berisi hal-hal
- Hal-hal yang terkandung disebut anggota (bukan daftar nilai)
Koleksi RDF
Koleksi RDF menggambarkan grup yang HANYA dapat berisi anggota yang ditentukan.
Atribut rdf:parseType="Koleksi"
Seperti yang terlihat di bab sebelumnya, sebuah wadah mengatakan bahwa sumber daya yang berisi adalah anggota - tidak mengatakan bahwa anggota lain tidak diperbolehkan.
Koleksi RDF digunakan untuk menggambarkan grup yang HANYA dapat berisi anggota yang ditentukan.
Koleksi dideskripsikan dengan atribut rdf:parseType="Collection".
Contoh
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://recshop.fake/cd#">
<rdf:Description
rdf:about="http://recshop.fake/cd/Beatles">
<cd:artist rdf:parseType="Collection">
<rdf:Description rdf:about="http://recshop.fake/cd/Beatles/George"/>
<rdf:Description rdf:about="http://recshop.fake/cd/Beatles/John"/>
<rdf:Description rdf:about="http://recshop.fake/cd/Beatles/Paul"/>
<rdf:Description rdf:about="http://recshop.fake/cd/Beatles/Ringo"/>
</cd:artist>
</rdf:Description>
</rdf:RDF>
Skema RDF dan Kelas Aplikasi
Skema RDF (RDFS) adalah perpanjangan dari RDF.
RDF menjelaskan sumber daya dengan kelas, properti, dan nilai.
Selain itu, RDF juga membutuhkan cara untuk mendefinisikan kelas dan properti khusus aplikasi. Kelas dan properti khusus aplikasi harus ditentukan menggunakan ekstensi ke RDF.
Salah satu ekstensi tersebut adalah Skema RDF.
Skema RDF (RDFS)
Skema RDF tidak menyediakan kelas dan properti khusus aplikasi yang sebenarnya.
Sebaliknya Skema RDF menyediakan kerangka kerja untuk menggambarkan kelas dan properti khusus aplikasi.
Classes in RDF Schema are much like classes in object oriented programming languages. This allows resources to be defined as instances of classes, and subclasses of classes.
RDFS Example
The following example demonstrates some of the RDFS facilities:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xml:base="http://www.animals.fake/animals#">
<rdf:Description rdf:ID="animal">
<rdf:type
rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
</rdf:Description>
<rdf:Description rdf:ID="horse">
<rdf:type
rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/>
<rdfs:subClassOf rdf:resource="#animal"/>
</rdf:Description>
</rdf:RDF>
In the example above, the resource "horse" is a subclass of the class "animal".
Example Abbreviated
Since an RDFS class is an RDF resource we can abbreviate the example above by using rdfs:Class instead of rdf:Description, and drop the rdf:type information:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xml:base="http://www.animals.fake/animals#">
<rdfs:Class rdf:ID="animal" />
<rdfs:Class rdf:ID="horse">
<rdfs:subClassOf rdf:resource="#animal"/>
</rdfs:Class>
</rdf:RDF>
That's it!
The Dublin Core
The Dublin Core Metadata Initiative (DCMI) has created some predefined properties for describing documents.
RDF is metadata (data about data). RDF is used to describe information resources.
The Dublin Core is a set of predefined properties for describing documents.
The first Dublin Core properties were defined at the Metadata Workshop in Dublin, Ohio in 1995 and is currently maintained by the Dublin Core Metadata Initiative.
Property | Definition |
---|---|
Contributor | An entity responsible for making contributions to the content of the resource |
Coverage | The extent or scope of the content of the resource |
Creator | An entity primarily responsible for making the content of the resource |
Format | The physical or digital manifestation of the resource |
Date | A date of an event in the lifecycle of the resource |
Description | An account of the content of the resource |
Identifier | An unambiguous reference to the resource within a given context |
Language | A language of the intellectual content of the resource |
Publisher | An entity responsible for making the resource available |
Relation | A reference to a related resource |
Rights | Information about rights held in and over the resource |
Source | A Reference to a resource from which the present resource is derived |
Subject | A topic of the content of the resource |
Title | A name given to the resource |
Type | The nature or genre of the content of the resource |
A quick look at the table above indicates that RDF is ideal for representing Dublin Core information.
RDF Example
The following example demonstrates the use of some of the Dublin Core properties in an RDF document:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc= "http://purl.org/dc/elements/1.1/">
<rdf:Description rdf:about="https://www.w3schools.com">
<dc:description>W3Schools - Free tutorials</dc:description>
<dc:publisher>Refsnes Data as</dc:publisher>
<dc:date>2008-09-01</dc:date>
<dc:type>Web Development</dc:type>
<dc:format>text/html</dc:format>
<dc:language>en</dc:language>
</rdf:Description>
</rdf:RDF>
RDF Reference
The RDF namespace (xmlns:rdf) is: http://www.w3.org/1999/02/22-rdf-syntax-ns#
The RDFS namespace (xmlns:rdfs ) is: http://www.w3.org/2000/01/rdf-schema#
The recommended file extension for RDF files is .rdf. However, the extension .xml is often used to provide compatibility with old xml parsers.
The MIME type should be "application/rdf+xml".
RDFS / RDF Classes
Element | Class of | Subclass of |
---|---|---|
rdfs:Class | All classes | |
rdfs:Datatype | Data types | Class |
rdfs:Resource | All resources | Class |
rdfs:Container | Containers | Resource |
rdfs:Literal | Literal values (text and numbers) | Resource |
rdf:List | Lists | Resource |
rdf:Property | Properties | Resource |
rdf:Statement | Statements | Resource |
rdf:Alt | Containers of alternatives | Container |
rdf:Bag | Unordered containers | Container |
rdf:Seq | Ordered containers | Container |
rdfs:ContainerMembershipProperty | Container membership properties | Property |
rdf:XMLLiteral | XML literal values | Literal |
RDFS / RDF Properties
Element | Domain | Range | Description |
---|---|---|---|
rdfs:domain | Property | Class | The domain of the resource |
rdfs:range | Property | Class | The range of the resource |
rdfs:subPropertyOf | Property | Property | The property is a sub property of a property |
rdfs:subClassOf | Class | Class | The resource is a subclass of a class |
rdfs:comment | Resource | Literal | The human readable description of the resource |
rdfs:label | Resource | Literal | The human readable label (name) of the resource |
rdfs:isDefinedBy | Resource | Resource | The definition of the resource |
rdfs:seeAlso | Resource | Resource | The additional information about the resource |
rdfs:member | Resource | Resource | The member of the resource |
rdf:first | List | Resource | |
rdf:rest | List | List | |
rdf:subject | Statement | Resource | The subject of the resource in an RDF Statement |
rdf:predicate | Statement | Resource | The predicate of the resource in an RDF Statement |
rdf:object | Statement | Resource | The object of the resource in an RDF Statement |
rdf:value | Resource | Resource | The property used for values |
rdf:type | Resource | Class | The resource is an instance of a class |
RDF Attributes
Attribute | Description |
---|---|
rdf:about | Defines the resource being described |
rdf:Description | Container for the description of a resource |
rdf:resource | Defines a resource to identify a property |
rdf:datatype | Defines the data type of an element |
rdf:ID | Defines the ID of an element |
rdf:li | Defines a list |
rdf:_n | Defines a node |
rdf:nodeID | Defines the ID of an element node |
rdf:parseType | Defines how an element should be parsed |
rdf:RDF | The root of an RDF document |
xml:base | Defines the XML base |
xml:lang | Defines the language of the element content |