Properties
We saw that in RDF properties are defined as a type of resource. We can use properties to ensure that statements in our knowledge base are well-formed and valid, by using the domain and range attributes.
The property rdfs:domain restricts the set of resources that may have a given property (restricts which subjects the property can be applied to). The property rdfs:range restricts the set of values for a given property (restricts which objects the property can specify). If a domain or range specifies a class, then all sub-classes of that class (but not super-classes) will also be allowed. A property can have many ranges and domains.
We can also define a hierarchy of properties, in the same way that we define a hierarchy of properties, using the rdfs:subPropertyOf relation. Sub-properties inherit their domain and range from the super-property, and can also specify additional ones.
<?xml version="1.1"?>
<!DOCTYPE rdf:RDF [
<!ENTITY xsd http://www.w3.org/20001/XMLSchema#>
<!ENTITY rdf http://www.w3.org/1999/02/22-rdf-syntax-ns>
]>
<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.mycomputer.org/photo#>
<rdf:Property rdf:ID="manufacturer">
<rdfs:domain rdf:resource="#ComputerType" />
<rdfs:range rdf:resource="#Manfacturer" />
</rdf:Property>
<rdf:Property rdf:ID="model>
<rdfs:range rdf:resource="#ModelType" />
<rdfs:subPropertyOf rdf:resource="#manufacturer" />
</rdf:Property>
<rdf:Property rdf:ID="comesInColours">
<rdfs:domain rdf:resource="#ComputerColours"/>
<rdfs:range rdf:resource="&rdf;Alt" />
</rdf:Property>
</rdf:RDF>
Code adapted from Agency and the Semantic Web by Walton (2007), p35.