RDF Documents

An RDF document consists of a list of descriptions, each of which is the description of an RDF triple. Different RDF documents can be combined, to create a vast structure of knowledge made up of individual triples, often referred to as a semantic network.

To define a complete RDF document we encompass a list of rdf:Description elements with an enclosing rdf:RDF element.

rdf:Resource - In order to create a link between an object and a subject, we can use the rdf:Resource attribute.

rdf:ID - In our earlier example, we saw the rdf:about attribute used to provide the URI reference to the MacBookAir. However, another way to reference this URI would have been to use the rdf:Resource or rdf:ID attributes. Rdf:about refers to an existing resource, whereas rdf:ID generates an ID by combining the URI of the document with the identifier given. This identifier must be given in the form '#value'. Rdf:ID allows the description to be referenced externally, e.g. http://www.mycomputer.org/photos#MacBookAir.

Literal Values - However, it is not always necessary to use a URI as the object of a statement. For example, if we say that the MacBookAir has weight 3.0, then, while it is necessary to assign the subject 'MacBookAir' and the property 'has weight' to fixed URIs, it seems easier to simply include the value of 3 directly, rather than assigning it to a URI. To do this we can use literal values (note that these can only be used as the object of a triple, and not as the subject or predicate). The standard data types are specified using xml schema types. For example, the decimal type has the URI http://www.w3.org/2001/XMLSchema#decimal.

Literal Types using Entity Declarations - However, an added complication is that namespaces cannot be used within a string, so we would have to write the complete URI every time. Instead, we could use an entity declaration, for example, we associate the name xsd with the string http://www.w3.org/2001/XMLSchema#. When we later write &xsd, this name is substituted.

Data Types - Sometimes it is enough to give a data value simply on its own. However, if we wanted to describe the computer's price, the number given could be in pounds, euros, dollars, etc. We need to specify a unit. Therefore, the value is given between <rdf:value> and </rdf:value> tags, and the type is given between <rdf:type> and </rdf:type> tags.

Blank Nodes - We can define nodes that do not contain resources by using blank node identifiers. This is useful as a placeholder where we do not know what the resource is, or for grouping resources together.

Containers - A container is a resource that contains either literal values or other resources. It enables us to talk about a group of things as a whole. In RDF there are three types available:

We have a choice of either explicitly numbering the items, or simply using the li format. This is useful when we want to be able to add and remove items easily.

Closed containers - RDF does not provide a way to state that a container contains all the possible members it could ever have. Instead, we can use rdf:parseType="Collection". This has the effect of saying that a computer can be either a desktop or a laptop, and no other.

Reification - Reification allows us to make statements about other statements. For example, Apple may say that the MacBookAir has the operating system Leopard. To maintain the idea of this being something that Apple has said, we treat the whole statement as a resource.