|
From: Richard C. <ri...@cy...> - 2006-04-19 10:10:44
|
Hi Antonia,
On 14 Apr 2006, at 09:19, =EC=96=91=EA=B2=BD=EC=95=84 wrote:
> I'm a beginner for RAP and PHP.
Welcome!
> I'm trying to get ontClaess by using listClasses()
>
> $array =3D ontModel->listClass();
Variables in PHP *always* have a dollar sign in front of the name. So =20=
it should be $ontModel. The method is also called listClasses, not =20
listClass.
> foreach( $array as $resource){
> $ontClass =3D (OntClass) $resource;
Usually you don't do typecasting in PHP. This is not Java ;-)
You still need to turn the resource into an ontClass though:
$ontClass =3D $ontModel->createOntClass($resource->getURI());
> $arrayClass =3D $ontClass->listSubClasses(true);
> }
>
> You know It occurs an error.
(In general, it's helpful if you say *what* error occurs. This often =20
saves us some time.)
> Is there anybody to teach me a tip of this problem.
Here's a simple complete script that works for me:
include(RDFAPI_INCLUDE_DIR . "RdfAPI.php");
$model =3D ModelFactory::getDefaultModel();
$model->load('http://protege.stanford.edu/plugins/owl/owl-library/=20
camera.owl');
$ontModel =3D ModelFactory::getOntModelForBaseModel($model, =20
RDFS_VOCABULARY);
$array =3D $ontModel->listClasses();
foreach($array as $resource){
echo "Listing subclasses of " . $resource->getURI() . "\n";
$ontClass =3D $ontModel->createOntClass($resource->getURI());
$arrayClass =3D $ontClass->listSubClasses(true);
foreach ($arrayClass as $subclass) {
echo $subclass->getLabel() . "\n";
}
}
Best,
Richard
>
>
>
>
> Sincerely
>
> Antonia
>
|