Within RDF Schema, constraints define class associations for properties. In addition, there are subclasses of both Property and Resource that are specific to constraints.
In Example 5-4, the rdfs:domain property was used to associate a property with the resource it modified. It was used with both the author and title properties to associate them with the Article resource. The RDF Schema property is further constrained to be used only with properties by specifying an rdfs:domain of Property for the rdfs:domain itself.
An RDF property can be used for more than one resource type. Something such as title can then be used for Article but can also be used for Person (a person's work title), as well as something such as Painting (title of a painting). The only limitation is the domain scope. The rdfs:range property is used to specify the classes the property can reference as values. Unlike the domain element, only one RDF range constraint can be attached to any property?equivalent to the restriction in most programming languages that a variable can be of only one data type, constraining the allowable values that the variable can contain.
To specify more than one class as range constraint for a property (more than one data type if you will), you can use a master class for all classes that will be designated by a specific range and then use inheritance to extend the class with sub-classes.
In Example 5-5, a new class is added to the example schema called Directory. This class has one property, contains, which is used to identify web resources the directory contains. A new contains property is created and tied back to the class through the rdfs:domain property.
The web resources can be articles or examples; to allow both in the new contains range, a master class, WebPage, is created; it is then refined through the use of rdfs:subClassOf to create Article and Example classes. The master class is used as the value for the rdfs:range property of the contains class.
<?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/WebPage"> <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://burningbird.net/postcon/elements/1.0/WebPage"/> </rdfs:Class> <rdfs:Class rdf:about="http://burningbird.net/postcon/elements/1.0/Example"> <rdfs:subClassOf rdf:resource="http://burningbird.net/postcon/elements/1.0/WebPage"/> </rdfs:Class> <rdfs:Class rdf:about="http://burningbird.net/postcon/elements/1.0/Directory"> <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/contains"> <rdfs:domain rdf:resource="http://burningbird.net/postcon/elements/1.0/Directory" /> <rdfs:range rdf:resource="http://burningbird.net/postcon/elements/1.0/WebPage" /> </rdf:Property> </rdf:RDF>