5.2 Core RDF Schema Elements


5.2 Core RDF Schema Elements

The RDF Schema elements are marked by a specific namespace, identified within a document with the following namespace declaration:

 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 

Within the Schema Specification, there is a core group of classes and properties used to describe domain-specific RDF elements. These, combined with a specific set of constraints (described later in Section 5.3), form the foundation of the schema.

RDF Schema elements are defined in the RDFMS as well as within the RDF Schema. RDFMS elements are identified with the rdf namespace:

 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 

5.2.1 Overview of the RDF Classes

There are surprisingly few RDF Schema classes:

rdfs:Resource

All resources within RDF are implicitly members of this class.

rdfs:Class

Type or category of resource.

rdfs:Literal

Literals within RDF documents, such as text strings.

rdfs:XMLLiteral

Literals with RDF documents that use XML syntax.

rdfs:Container

Superclass of all container classes.

rdfs:ContainerMembershipProperty

Members of containers.

rdfs:Datatype

Data typing information.

Taking a closer look at each of these classes, the rdfs:Resource element is used to describe a basic resource within the RDF. It is the set of these elements that literally forms both the reason and focus of the entire RDF specification.

Example 5-1 demonstrates a very simple RDF/XML document that contains a description of an article, including the article's title and author.

Example 5-1. Demonstrating the explicit resource property type
 <?xml version="1.0"?> <rdf:RDF   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"   xmlns:pstcn="http://burningbird.net/postcon/elements/1.0/">   <rdf:Description rdf:about="http://burningbird.net/articles/monsters3.htm">     <pstcn:author>Shelley Powers</pstcn:author>     <pstcn:title>Architeuthis Dux</pstcn:title>   </rdf:Description> </rdf:RDF> 

Every resource within an RDF document, such as the article shown in Example 5-1, has a common ancestor class: rdfs:Resource . Because of this commonality , you generally won't see an explicit use of rdfs:Resource within an RDF vocabulary document. However, if you did, you would see it used in a manner similar to the following schema representation of the article resource from Example 5-1:

 <rdfs:Class rdf:ID="Article"> <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource" /> </rdfs:Class> 

The RDF fragment also uses rdfs:Class . All new resource types are identified by an rdfs:Class statement, including the rdfs:Resource element itself. The Class element is very similar to its same- name counterpart in object-oriented development ”a unique object that can be described and can have associated behaviors.

In the RDF Schema Specification, the rdf:Description element is also used to identify a particular class.

Within the RDF Schema, RDF properties (discussed in the next section) have a given range of allowable values, such as rdfs:Class , rdfs:Property , or rdfs:Literal . The last is used to describe what the Schema Specification terms self-denoting nodes , which are nodes that can contain literals such as strings. An example of one such property is rdfs:Comment , used as follows :

 <rdfs:Comment>This is a comment within the RDF Schema</rdfs:Comment> 

The comment's value is a text string, a literal, parsed out in its entirety without additional processing.

rdfs:Container is the superclass of all RDF container elements: rdf:Bag , rdf:Seq , and rdf:Alt . The rdfs:ContainerMembershipProperty class consists of the Container elements themselves (usually denoted by _1 , _2 , _3 , and so on). It also contains rdfs:member .

The rdfs:Datatype class is the class of all data types and is, itself, a subclass of rdfs:Literal . The data type values follow the constraints defined for RDF data types, covered in Chapter 2 and Chapter 3, which means that there is a mapping of both the value as well as the data type.

Actual instances of data types are recorded using rdf:datatype within each instance, basically associating each field with a specific data type. However, you can specify a data type within the schema, also, but there's nothing associated with RDF Schemas that would enforce data types between the schema and each instance. This disconnect can potentially lead to some problems, as detailed in Chapter 6.

rdfs:XMLLiteral is a subclass of rdfs:Literal and an instance of rdfs:Datatype , and is the class of all XML literals. This is somewhat equivalent to CDATA within XML and HTML, and allows one to embed XML into the RDF/XML document that is not processed as RDF/XML. Associated with the XML is an arbitrary but fixed pattern:

 "<rdf-wrapper xml:lang='"   lang   "'>"   str   "</rdf-wrapper>" 

According to the document, rdf-wrapper is arbitrary but fixed. This means that the format remains the same, but the actual element names can differ . This makes sense ”whatever is contained within the field designated as XMLLiteral would, we assume, follow standard XML formatting.

In addition to the RDF Schema classes, a few RDF classes cross the boundary between the metalanguage and instances of the same. These are:

rdf:Statement

Class of all RDF statements

rdf:Bag , rdf:Seq , and rdf:Alt

Container classes

rdf:List

Class of all RDF lists

rdf:Property

Resources that are RDF properties

The rdf:Statement class includes as members all reified RDF statements within a vocabulary (all resources that have an rdf:type of rdf:Statement ).

The container classes ” rdf:Bag , rdf:Seq , and rdf:Alt ” are used to group members, positioning within the grouping dependent on the type of container class (Chapter 4 goes into detail on the container classes).

The rdf:List class has as members all RDF lists within a vocabulary, as rdfs:Container is a superclass of all RDF container elements.

The rdf:Property class is used to define the attributes that, in turn , describe the resource. In Example 5-1, the attributes for Article are author and title . The minimum RDF Schema definition that could describe the RDF/XML used in this example resource are shown in Example 5-2.

Example 5-2. RDF Schema for Article
 <?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#"   xmlns:pstcn="http://burningbird.net/postcon/elements/1.0/"> <rdfs:Class rdf:about="http://burningbird.net/postcon/elements/1.0/Article">   <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/> </rdfs:Class> <rdf:Property rdf:about="http://burningbird.net/postcon/elements/1.0/title">   <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" /> </rdf:Property> <rdf:Property rdf:about="http://burningbird.net/postcon/elements/1.0/author">   <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" /> </rdf:Property> </rdf:RDF> 

In this document, Article is defined as an rdf:Resource (subclass of the Resource class), and each property of Article ( title and author ) is related to it through the use of the RDF Schema domain constraint (discussed in Section 5.3).

The Article class and its associated properties are associated with the Resource and Property classes, respectively, through the subClassOf property. This and other core RDF properties are discussed next.

5.2.2 Demonstrations of the RDF Schema Properties

The RDF specification's purpose is purely to define resources and associated facts, and then provide a way to allow these resource/fact mappings to interact. This is accomplished through capturing statements about the resource, with each statement consisting of a specific property such as title and author for the Article resource. The RDF Schema is no exception ”statements about each resource are captured as individual properties. The only difference between the two is that one is an instance of business data (such as Article ), and the other is metadata (related to the RDF model).

Following are the core properties (from both the RDF and RDFS namespaces) that are essential to the RDF Schema:

  • rdfs:subClassOf

  • rdfs:subPropertyOf

  • rdfs:seeAlso

  • rdfs:isDefinedBy

  • rdfs:member

  • rdfs:comment

  • rdfs:label

  • rdf:type

  • rdf:subject

  • rdf:predicate

  • rdf:object

  • rdf:first

  • rdf:rest

  • rdfs:domain

  • rdfs:range

  • rdf:value

The rdf:value property was described in Chapter 3. The rdf:subClassOf property identifies a class that is a subclass of another. For instance, in Example 5-2, Article is a subclass of the more generic Resource class, which all resources belong to. Article could also be a subclass of another class such as WebPage, which is, in turn, a subclass of Resource, as demonstrated in the following RDF/XML snippet:

 <rdfs:Class rdf:ID="WebPage">   <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/> </rdfs:Class> <rdfs:Class rdf:ID="Article">   <rdfs:subClassOf rdf:resource="http://burningbird.net/schema#WebPage"/> </rdfs:Class> 

The use of inheritance within the RDF Schema classes allows us to define super-classes such as WebPage. New subclasses of WebPage then not only inherit the properties and constraints of the superclass Resource, they also inherit the additional properties and constraints from WebPage.

The rdfs:subPropertyOf property is used when one property is a refinement of another property. For instance, in the Article schema, one of the properties is author . This property could be further refined to specify whether an author is a primary or secondary author, via the primaryAuthor and secondaryAuthor subproperties , respectively. Example 5-3 shows the use of this property refinement through the rdfs:subPropertyOf property.

Example 5-3. RDF Schema example of property refinement
 <?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#"   xmlns:pstcn="http://burningbird.net/postcon/elements/1.0/"> <rdfs:Class rdf:about="http://burningbird.net/postcon/elements/1.0/Article">   <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/> </rdfs:Class> <rdf:Property rdf:about="http://burningbird.net/postcon/elements/1.0/title">   <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" /> </rdf:Property> <rdf:Property rdf:about="http://burningbird.net/postcon/elements/1.0/author">   <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" /> </rdf:Property> <rdf:Property rdf:about="http://burningbird.net/postcon/elements/1.0/primaryAuthor">   <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" />   <rdfs:subPropertyOf rdf:resource="http://burningbird.net/postcon/elements/1.0/author" /> </rdf:Property> <rdf:Property rdf:about="http://burningbird.net/postcon/elements/1.0/secondaryAuthor">   <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" />   <rdfs:subPropertyOf rdf:resource="http://burningbird.net/postcon/elements/1.0/author" /> </rdf:Property> </rdf:RDF> 

The rdfs:seeAlso property is used to identify another resource that contains additional information about the resource being described. An example of using this property could be the following RDF fragment, showing the relationship between an article and a document maintaining the history of the article, identified as a class called ArticleHistory:

 <rdfs:Class rdf:about=" http://burningbird.net/postcon/elements/1.0/ArticleHistory">   <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/> </rdfs:Class> <rdfs:Class rdf:about=" http://burningbird.net/postcon/elements/1.0/Article">   <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>   <rdfs:seeAlso rdf:resource="http://burningbird.net/postcon/elements/1.0/ ArticleHistory" /> </rdfs:Class> 

Within the RDFS vocabulary, rdfs:seeAlso is also used to link the vocabulary document with a second document:

 <rdf:Description rdf:about="http://www.w3.org/2000/01/rdf-schema#">   <rdfs:seeAlso rdf:resource="http://www.w3.org/2000/01/rdf-schema-more"/> </rdf:Description> 

With this, additional schema elements can be added to the vocabulary without having to edit or modify the original schema.

According to the RDF Schema Specification, rdfs:seeAlso can be refined through the rdfs:subPropertyOf property to provide additional information about the manner in which the one resource provides additional information about the second resource:

 <rdf:Property rdf:about=" http://burningbird.net/postcon/elements/1.0/ historyProvidedBy">   <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-schema#Property"/>   <rdfs:subPropertyOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#seeAlso" /> </rdf:Property> <rdfs:Class rdf:about=" http://burningbird.net/postcon/elements/1.0/ArticleHistory">   <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/> </rdfs:Class> <rdfs:Class rdf:about=" http://burningbird.net/postcon/elements/1.0/Article">   <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>   <bbd:historyProvidedBy rdf:resource=" http://burningbird.net/postcon/elements/1.0/ ArticleHistory" /> </rdfs:Class> 

The rdfs:isDefinedBy property identifies the namespace for the resource, preventing any ambiguity or confusion about namespace ownership. For example, if a resource is identified by a GUID (Globally Unique Identifier), the rdfs:isDefinedBy property could be attached to the Resource class, to provide the URI for the schema.

Within the RDFS Schema vocabulary, the rdf:Statement class is defined to be a part of the RDF syntax namespace:

 <rdfs:Class rdf:about="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement">   <rdfs:isDefinedBy rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>   <rdfs:label xml:lang="en">Statement</rdfs:label>   <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>   <rdfs:comment>The class of RDF statements.</rdfs:comment> </rdfs:Class> 

However, the rdfs:Literal class is defined to be a part of the RDF Schema namespace:

 <rdfs:Class rdf:about="http://www.w3.org/2000/01/rdf-schema#Literal">   <rdfs:isDefinedBy rdf:resource="http://www.w3.org/2000/01/rdf-schema#"/>   <rdfs:label xml:lang="en">Literal</rdfs:label>   <rdfs:comment>This represents the set of atomic values, eg. textual strings.</rdfs: comment> </rdfs:Class> 

The rdfs:member property is a superproperty for each numbered container element (such as _1 , _2 , and so on).

At the time of this writing, the RDF Working Group is working to resolve whether rdfs:member should be a member of rdfs:ContainerMembershipProperty . Check the RDF Schema specification for final resolution of this issue.

Two properties provide human readability to an RDF model. The rdfs:comment property is used to provide documentation of resources, and rdfs:label provides a readable version of the resource's name. In addition, you can attach the XML attribute xml:lang to the rdfs:label element and provide different labels for different languages.

You can add comments to an RDF/XML document using XML comments such as the following:

 <!--Class defining Web articles--> <rdfs:Class rdf:about="http://burningbird.net/postcon/elements/1.0/Article">   <rdfs:subClassOf rdf:Resource="http://www.w3.org/2000/01/rdf-schema#Resource"/> </rdfs:Class> 

However, to formally attach documentation to an element in such a way that the documentation itself can be easily accessible through RDF parsers or other automated processes, then you need to have RDF Schema elements that can be used specifically for schema documentation. These elements are rdfs:comment and rdfs:label . The rdfs:comment provides a description of the resource, while the rdfs:label provides a human-readable version of the name.

Adding documentation to Example 5-3 results in the RDF/XML shown in Example 5-4. As you can see, just a few extra lines can provide considerable information.

Example 5-4. Using RDF Schema documentation elements
 <?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#"   xmlns:pstcn="http://burningbird.net/postcon/elements/1.0/"> <rdfs:Class rdf:about="http://burningbird.net/postcon/elements/1.0/Article">   <rdfs:subClassOf rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>   <rdfs:comment>Unique Online article</rdfs:comment>   <rdfs:label  xml:lang="en">Article</rdfs:label>  </rdfs:Class> <rdf:Property rdf:about="http://burningbird.net/postcon/elements/1.0/title">   <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-schema#Property"/>   <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" />   <rdfs:comment>Online Article Title</rdfs:comment>   <rdfs:label xml:lang="en">Title</rdfs:label> </rdf:Property> <rdf:Property rdf:about="http://burningbird.net/postcon/elements/1.0/author">   <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-schema#Property"/>   <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" />   <rdfs:comment>Primary author of article</rdfs:comment>   <rdfs:label xml:lang="en">Author</rdfs:label> </rdf:Property> </rdf:RDF> 

When viewing the schema in Example 5-3, you can understand what's being described because you have this chapter to provide information. However, in real life, a vocabulary and schema may not have associated documentation, or the link between the documentation and the vocabulary may not be maintained . By providing both comments and a readable label, you're providing information to the users about exactly what's being defined. This is no different than providing inline documentation and using good naming practices within code among application developers.

The rdf:type property defines the type of resource. As mentioned earlier, all resources are of type Resource , as well as being a more granular type, such as Article . The type property designates that the resource being referenced is an instance of this class.

Within an RDF/XML document, the rdf:type is usually assumed and isn't explicitly given. However, you can explicitly use the rdf:type property to remove any possibility of confusion between the RDF/XML document and N-Triples or an RDF graph generated from the document. This holds true for RDF Schema vocabulary documents. For instance, you can attach an rdf:type property to the author property to refine the definition, though its use in a schema is usually redundant.

 <rdf:Property rdf:about="http://burningbird.net/postcon/elements/1.0/author">   <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-schema#Property"/>   <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" />   <rdfs:comment>Primary author of article</rdfs:comment>   <rdfs:label xml:lang="en">Author</rdfs:label>  <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property" />  </rdf:Property> 

The rdf:subject , rdf:predicate , and rdf:object properties are used with reification to explicitly define an RDF statement. In addition, the rdf:first and rdf:next properties are used to explicitly define the relationships within a collection. Since both reification and collections are covered in depth in Chapter 4, I won't repeat the details here.

The remaining two properties, rdfs:domain and rdfs:range , are described in the next section.



Practical RDF
Practical RDF
ISBN: 0596002637
EAN: 2147483647
Year: 2003
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net