3.5 The rdf:type Property


One general piece of information that is consistent about an RDF resource ”outside of the URI to uniquely identify it ”is the resource or class type. In the examples shown thus far, this value could implicitly be "Web Resource" to refer to all of the resources, or could be explicitly set to "article" for articles. All these would be correct, depending on how generically you want to define the resource and the other properties associated with the resource. To explicitly define the resource type, you would use the RDF rdf:type property.

Usually the rdf:type property is associated at the same level of granularity as the other properties. As the resources defined using RDF in this chapter all have properties associated more specifically with an article than a web resource, the RDF type property would be "article" or something similar.

In the next section, covering RDF containers, we will learn that the resource type for an RDF container would be the type of container rather than the type of the contained property or resource. Again, the type is equivalent to the granularity of the resource being described, and with containers, the resource is a canister (or group ) of resources or properties rather than a specific resource or property.

The value of the RDF rdf:type property is a URI identifying an rdfs:Class -typed resource ( rdfs:Class is described in detail in Chapter 5). To demonstrate how to attach an explicit type to a resource, Example 3-13 shows the resource defined in the RDF/XML for Example 3-1, but this time explicitly defining an RDF Schema element for the resource.

Example 3-13. 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:type rdf:resource="http://burningbird.net/postcon/elements/1.0/Article" />  </rdf:Description> </rdf:RDF> 

The type property includes a resource reference for the schema element, in this case for the Article class.

Rather than formally list out an rdf:Description and then attach the rdf:type predicate to it, you can cut through all of that using an RDF/XML shortcut. Incorporating the formal syntax of the type property directly into XML, as before, the type property is treated as an embedded element of the outer resource.

Within the shortcut, the type property is created directly as the element type rather than as a generic RDF Description element. This new syntax, demonstrated in Example 3-14, leads to correct interpretation of the RDF within an XML parser.

Example 3-14. Abbreviated syntax version of type property
 <?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/">  <pstcn:Article rdf:about="http://burningbird.net/articles/monsters3.htm">  <pstcn:Author>Shelley Powers</pstcn:Author>     <pstcn:Title>Architeuthis Dux</pstcn:Title>  </pstcn:Article>  </rdf:RDF> 

Notice the capitalization of the first letter for Article . This provides a hint that the element is a resource, rather than a predicate type.

This shortcut approach is particularly effective in ensuring that there is no doubt as to the nature of the resource being described, especially since formally listing an rdf:type predicate isn't a requirement of the RDF/XML. As you'll see later, in Chapter 6, the PostCon vocabulary uses this shortcut technique to identify the major resource as a web document.

Other RDF/XML shortcuts that can help cut through some of the rather stylized RDF/XML formalisms and make the underlying model a little more opaque are described in the next section.

An RDF resource can have more than one rdf:type associated with it.



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