XML RDF
مثال على وثيقة 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>
ما هو RDF؟
- RDF هي اختصار لـ R esource D escription F ramework
- RDF هو إطار عمل لوصف الموارد على الويب
- تم تصميم RDF ليتم قراءتها وفهمها بواسطة أجهزة الكمبيوتر
- لم يتم تصميم RDF ليتم عرضها على الأشخاص
- تمت كتابة RDF في XML
- RDF هو جزء من نشاط الويب الدلالي لـ W3C
- RDF هي توصية W3C من 10. فبراير 2004
RDF - أمثلة على الاستخدام
- وصف خصائص عناصر التسوق ، مثل السعر والتوافر
- وصف الجداول الزمنية لأحداث الويب
- وصف المعلومات حول صفحات الويب (المحتوى ، المؤلف ، تاريخ الإنشاء والتعديل)
- وصف المحتوى والتصنيف لصور الويب
- وصف المحتوى لمحركات البحث
- وصف المكتبات الإلكترونية
تم تصميم RDF لتتم قراءته بواسطة أجهزة الكمبيوتر
تم تصميم RDF لتوفير طريقة مشتركة لوصف المعلومات بحيث يمكن قراءتها وفهمها بواسطة تطبيقات الكمبيوتر.
لم يتم تصميم أوصاف RDF ليتم عرضها على الويب.
تمت كتابة RDF بلغة XML
تتم كتابة مستندات RDF بتنسيق XML. لغة XML التي يستخدمها RDF تسمى RDF / XML.
باستخدام XML ، يمكن بسهولة تبادل معلومات RDF بين أنواع مختلفة من أجهزة الكمبيوتر باستخدام أنواع مختلفة من أنظمة التشغيل ولغات التطبيق.
RDF و "الويب الدلالي"
لغة RDF هي جزء من نشاط الويب الدلالي لـ W3C. "رؤية الويب الدلالية" الخاصة بـ W3C هي مستقبل حيث:
- معلومات الويب لها معنى دقيق
- يمكن فهم معلومات الويب ومعالجتها بواسطة أجهزة الكمبيوتر
- يمكن لأجهزة الكمبيوتر دمج المعلومات من الويب
يستخدم RDF معرّفات الويب (URIs) لتحديد الموارد.
يصف RDF الموارد بالخصائص وقيم الممتلكات.
موارد RDF والممتلكات وقيمة الممتلكات
يحدد RDF الأشياء باستخدام معرفات الويب (URIs) ، ويصف الموارد بالخصائص وقيم الخصائص.
شرح قيمة الموارد والممتلكات والممتلكات:
- المورد هو أي شيء يمكن أن يحتوي على URI ، مثل "https://www.w3schools.com/rdf"
- الخاصية هي مورد له اسم ، مثل "المؤلف" أو "الصفحة الرئيسية"
- قيمة الخاصية هي قيمة الخاصية ، مثل "Jan Egil Refsnes" أو "https://www.w3schools.com" (لاحظ أن قيمة الخاصية يمكن أن تكون موردًا آخر)
يمكن أن يصف مستند RDF التالي المورد "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>
المثال أعلاه مبسط. تم حذف مساحات الأسماء.
بيانات RDF
يشكل الجمع بين المورد والممتلكات وقيمة الخاصية بيانًا (يُعرف باسم موضوع البيان وموضوعه وموضوعه ).
دعنا نلقي نظرة على بعض أمثلة العبارات لفهم أفضل:
بيان: "مؤلف https://www.w3schools.com/rdf هو Jan Egil Refsnes".
- موضوع البيان أعلاه هو: https://www.w3schools.com/rdf
- المسند: المؤلف
- الكائن: جان إجيل ريفسنس
البيان: "الصفحة الرئيسية لـ https://www.w3schools.com/rdf هي https://www.w3schools.com".
- موضوع البيان أعلاه هو: https://www.w3schools.com/rdf
- المسند هو: الصفحة الرئيسية
- الهدف هو: https://www.w3schools.com
مثال RDF
فيما يلي تسجيلان من قائمة الأقراص المضغوطة:
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 |
يوجد أدناه بضعة أسطر من مستند 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>
السطر الأول من وثيقة RDF هو إعلان XML. إعلان XML متبوع بالعنصر الجذر لوثائق RDF: <rdf: RDF> .
تحدد مساحة الاسم xmlns: rdf أن العناصر ذات البادئة rdf هي من مساحة الاسم "http://www.w3.org/1999/02/22-rdf-syntax-ns#".
تحدد مساحة الاسم xmlns: cd أن العناصر ذات بادئة القرص المضغوط هي من مساحة الاسم "http: //www.recshop.fake/cd#".
يحتوي العنصر <rdf: الوصف> على وصف المورد المحدد بواسطة rdf: about السمة.
العناصر: <cd: artist>، <cd: country>، <cd: company> وما إلى ذلك هي خصائص المورد.
RDF المدقق على الإنترنت
خدمة التحقق من صحة RDF الخاصة بـ W3C مفيدة عند تعلم RDF. هنا يمكنك تجربة ملفات RDF.
يقوم RDF Validator عبر الإنترنت بتحليل مستند RDF الخاص بك ، والتحقق من بناء الجملة الخاص بك ، وإنشاء عروض جدولية ورسومية لمستند RDF الخاص بك.
انسخ والصق المثال أدناه في مدقق 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>
عندما تحلل المثال أعلاه ، ستبدو النتيجة على هذا النحو .
عناصر RDF
العناصر الرئيسية لـ RDF هي عنصر الجذر ، <RDF> ، وعنصر <الوصف> ، الذي يحدد المورد.
العنصر <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: الوصف>
يحدد العنصر <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>
يتم تحديد العناصر والفنان والبلد والشركة والسعر والسنة في http://www.recshop.fake/cd# مساحة الاسم. مساحة الاسم هذه خارج RDF (وليست جزءًا من RDF). يحدد 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:country="USA"
cd:company="Columbia" cd:price="10.90"
cd:year="1985" />
</rdf: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 rdf:resource="http://www.recshop.fake/cd/dylan" />
...
...
</rdf:Description>
</rdf:RDF>
في المثال أعلاه ، ليس لفنان الخاصية قيمة ، بل إشارة إلى مورد يحتوي على معلومات حول الفنان.
حاويات RDF
تستخدم حاويات RDF لوصف مجموعة من الأشياء.
تُستخدم عناصر RDF التالية لوصف المجموعات: <حقيبة> و <مربع> و <ALT>.
العنصر <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: Seq> على قيم مكررة.
مثال
<?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: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>
شروط RDF
في الأمثلة أعلاه تحدثنا عن "قائمة القيم" عند وصف عناصر الحاوية. في RDF هذه "قائمة القيم" تسمى أعضاء.
لذلك لدينا ما يلي:
- الحاوية هي مورد يحتوي على أشياء
- الأشياء المحتواة تسمى أعضاء (وليس قائمة القيم)
مجموعات RDF
تصف مجموعات RDF المجموعات التي يمكن أن تحتوي فقط على الأعضاء المحددين.
ملف rdf: parseType = "Collection" سمة
كما رأينا في الفصل السابق ، تقول الحاوية أن الموارد المحتوية هي أعضاء - ولا تقول أن الأعضاء الآخرين غير مسموح بهم.
تُستخدم مجموعات RDF لوصف المجموعات التي يمكن أن تحتوي فقط على الأعضاء المحددين.
يتم وصف المجموعة بواسطة السمة rdf: parseType = "Collection".
مثال
<?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>
مخطط RDF وفئات التطبيق
مخطط RDF (RDFS) هو امتداد لـ RDF.
يصف RDF الموارد بالفئات والخصائص والقيم.
بالإضافة إلى ذلك ، يحتاج RDF أيضًا إلى طريقة لتحديد الفئات والخصائص الخاصة بالتطبيق. يجب تحديد الفئات والخصائص الخاصة بالتطبيق باستخدام ملحقات RDF.
أحد هذه الامتدادات هو مخطط RDF.
مخطط RDF (RDFS)
لا يوفر مخطط RDF فئات وخصائص خاصة بالتطبيق الفعلي.
بدلاً من ذلك ، يوفر مخطط RDF إطار عمل لوصف الفئات والخصائص الخاصة بالتطبيق.
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 |