This turorial is part of the RAP - Rdf API for PHP documentation.
RAP provides build-in support for the terms of a range of commonly known vocabularies. With version 0.9.1, RAP directly supports the following 8 vocabularies:
Vocabulary |
Website |
Specification |
RDF |
||
RDFS |
||
OWL |
||
Dublin Core (DC) |
http://dublincore.org/documents/dcmi-terms/ |
|
Friend of a Friend (FOAF) |
||
RSS |
||
ATOM |
http://www.atomenabled.org/developers/syndication/atom-format-spec.php |
|
VCARD |
This tutorial describes the usage of terms from these vocabularies within RAP.
1. | Including the Necessary Vocabulary Package |
2. | Using the Vocabulary |
In order to use a vocabulary you have to include the corresponding vocabulary package. The name of the file which you have to include depends on whether you are working on the RAP model layer model layer or on the RAP resource layer.
When you want to use FOAF together with a MemModel
you have to include:
|
In case of working with a ResModel
you have to include:
|
The following table lists all include packages for the different vocabularies:
Vocabulary |
Together with MemModel |
Together with ResModel |
RDF |
vocabulary/RDF_C.php |
vocabulary/RDF_RES.php |
RDFS |
vocabulary/RDFS_C.php |
vocabulary/RDFS_RES.php |
OWL |
vocabulary/OWL_C.php |
vocabulary/OWL_RES.php |
Dublin Core (DC) |
vocabulary/DC_C.php |
vocabulary/DC_RES.php |
Friend of a Friend (FOAF) |
vocabulary/FOAF_C.php |
vocabulary/FOAF_RES.php |
RSS |
vocabulary/RSS_C.php |
vocabulary/RSS_RES.php |
ATOM |
vocabulary/ATOM_C.php |
vocabulary/ATOM_RES.php |
VCARD |
vocabulary/VCARD_C.php |
vocabulary/VCARD_RES.php |
Now you are able to create resources for vocabulary terms by calling one simple method instead of generating them with $resouce = new Resource('uri')
. To create a RDFS- comment for example you have to call:
|
instead of:
|
If you included the PACKAGE_VOCABULARY_CLASS
package $comment is a Resource with the URI
http://www.w3.org/2000/01/rdf-schema#comment. If you included the PACKAGE_VOCABULARY_RES
package $comment is a ResResource with the same URI.
Normally the method to create a term is named like the term in the vocabulary using upper case. There are some reserved words in PHP like 'class' or 'list' so the methods to create these resources have other identifiers. To generate an OWL Class (http://www.w3.org/2002/07/owl#Class) for example use the method OWL::OWL_CLASS()
. To find out how these methods are named have a look at the corresponding vocabulary file.
For backward
compatibility
reasons, we are still supporting RAP 0.8's PACKAGE_VOCABULARY
package. Including this package will create MemModel resources for all terms in all vocabularies. This is very memory consuming and should thus be avoided.
In order to use the old vocabularies you have to include:
|