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はResourceD escription Frameworkの略です
- RDFは、Web上のリソースを記述するためのフレームワークです。
- RDFは、コンピューターによって読み取られ、理解されるように設計されています
- RDFは人々に表示されるようには設計されていません
- RDFはXMLで書かれています
- RDFはW3CのセマンティックWebアクティビティの一部です
- RDFは、2004年2月10日からのW3C勧告です。
RDF-使用例
- 価格や在庫状況など、ショッピングアイテムのプロパティを説明する
- Webイベントのタイムスケジュールの説明
- Webページに関する情報の説明(コンテンツ、作成者、作成日、変更日)
- Web画像のコンテンツと評価の説明
- 検索エンジンのコンテンツの説明
- 電子図書館の説明
RDFはコンピューターで読み取れるように設計されています
RDFは、情報を記述するための一般的な方法を提供するように設計されているため、コンピューターアプリケーションで情報を読み取って理解することができます。
RDFの説明は、Web上に表示されるようには設計されていません。
RDFはXMLで書かれています
RDFドキュメントはXMLで書かれています。RDFで使用されるXML言語はRDF / XMLと呼ばれます。
XMLを使用することにより、RDF情報は、さまざまな種類のオペレーティングシステムとアプリケーション言語を使用してさまざまな種類のコンピューター間で簡単に交換できます。
RDFと「セマンティックWeb」
RDF言語は、W3CのセマンティックWebアクティビティの一部です。W3Cの「セマンティックWebビジョン」は、次のような未来です。
- Web情報には正確な意味があります
- Web情報は、コンピューターで理解および処理できます
- コンピューターはWebからの情報を統合できます
RDFは、Web識別子(URI)を使用してリソースを識別します。
RDFは、プロパティとプロパティ値を使用してリソースを記述します。
RDFリソース、プロパティ、およびプロパティ値
RDFは、Web識別子(URI)を使用して物事を識別し、プロパティとプロパティ値を使用してリソースを記述します。
リソース、プロパティ、およびプロパティ値の説明:
- リソースとは、「https://www.w3schools.com/rdf」などのURIを持つことができるすべてのものです。
- プロパティは、「作成者」や「ホームページ」などの名前を持つリソースです。
- プロパティ値は、「Jan EgilRefsnes」や「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 EgilRefsnesです」。
- 上記の声明の主題は次のとおりです:https://www.w3schools.com/rdf
- 述語は次のとおりです。作成者
- オブジェクトは次のとおりです。JanEgilRefsnes
声明:「https://www.w3schools.com/rdfのホームページはhttps://www.w3schools.comです」。
- 上記の声明の主題は次のとおりです:https://www.w3schools.com/rdf
- 述語は次のとおりです。ホームページ
- オブジェクトは次のとおりです:https://www.w3schools.com
RDFの例
CDリストからの2つのレコードは次のとおりです。
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名前空間は、cdプレフィックスが付いた要素が名前空間 "http://www.recshop.fake/cd#"からのものであることを指定します。
<rdf:Description>要素には、rdf:about属性で識別されるリソースの説明が含まれています。
要素:<cd:artist>、<cd:country>、<cd:company>などはリソースのプロパティです。
RDFオンラインバリデーター
W3CのRDF検証サービスは、RDFを学習するときに役立ちます。ここでは、RDFファイルを試すことができます。
オンラインのRDFバリデーターは、RDF文書を解析し、構文をチェックし、RDF文書の表形式およびグラフ形式のビューを生成します。
以下の例をコピーして、W3Cの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.com</si:title>
<si:author>Jan Egil Refsnes</si:author>
</rdf:Description>
</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>
要素、アーティスト、国、会社、価格、および年は、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>
上記の例では、プロパティartistには値がありませんが、アーティストに関する情報を含むリソースへの参照があります。
RDFコンテナ
RDFコンテナは、物事のグループを記述するために使用されます。
次のRDF要素は、グループを記述するために使用されます:<Bag>、<Seq>、および<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>要素は、代替値のリストを記述するために使用されます(ユーザーは値の1つのみを選択できます)。
例
<?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の拡張機能を使用して定義する必要があります。
そのような拡張の1つが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 |