Rdfworld.php |
$feedrdf= file_get_contents("http://www.php.net/news.rss");
include_once("rdfworld.php");
$world= new World($feedrdf);
$channels= $world->getThingsByType("rss:channel");
$channel= $channels[0];
print "<h1>$channel->rss_title</h1>$channel->rss_description<hr />";
| Changelog: | |
| 2002-02-24: | Support for untyped Resources Namespace lookup from RDF if necessary World->addNamespace() - add to World->nsregistry |
| 2002-02-23: | Initial release |
| Variables: | |
| $rdf |
String: RDF describing World |
| $model |
Object: Model object returned by
RDF API for PHP |
| $nsregistry |
Array: associative array of
names and URLs of common namespaces. Example: rss=>http://purl.org/rss/1.0/ |
| $_populated |
Boolean: indicates that
populate() has been called (deprecated) |
| $_untypedResources |
Array: URIs of Resources without
rdf:type predicates. |
| Methods: |
|
| World(
$rdf="" ) |
|
| Creator method. If $rdf is provided, will populate() the World on creation. |
|
| populate(
$rdf ) |
|
| Parses $rdf using RDF API for
PHP and assigns the resulting Model to $this->model Note: future versions will allow multiple populate() calls per world in order to aggregate RDF from different sources. |
|
| getThingTypes() |
|
| Finds all of the valid types of
things present in the World. Returns an array of strings suitable for use as $typenames in getThingsByType($typename). |
|
| getThingsByType(
$typename ) |
|
| Finds all Resources in the World
with a particular rdf:type. $typename should be a string in the format ns:typename, like "rss:channel". For untyped Resources, use "rdfs:Resource" as $typename. Returns an array of Thing objects. |
|
| addNamespace($namespace,$key="") |
|
| Adds $namespace to
$this->nsregistry with short name $key. If $key is not specified, a unique name will be created (like ns1, ns2, etc.) Note that a number of common namespaces are defined in $this->nsregistry on creation and do not need to be added manually. They are: rdf, rdfs, rss, dc, foaf, cc, daml, log, doc, and content. |
|
| getNamespace(
$ns ) getNs( $namespace ) |
|
| Methods for looking up values in
the $this->nsregistry array. |
|
| Variables: | |
| $uri | String: URI of Thing |
| $type | String: rdf:type of thing |
| $model | Object: triples Model of self |
| $world | Object Reference: containing
World |
| $_ukindex | Integer: Index number used to
generate property names in case property name cannot be determined. |
| Methods: |
|
| Thing() |
|
| Creator method |
|
| fromModel(
$model, &$world ) |
|
| Takes a Model consisting of
triples about a single single RDF Resource and uses it to assign
property values to the Thing. Called by World->getThingsByType() in order to build Things. |
|
| getPropertiesList() |
|
| Generates an HTML listing of all
the properties of a Thing. Returns string. |
|
| $rdfworldroot |
String: directory containing
rdfworld-class.php |
| $rdfw_error |
String: HTML error channel used
by rdfwdebug() |
| rdfwdebug(
$message, $level=0 ) |
|
| |
Adds $message to $rdfw_error if
$level is less-than or equal-to $_REQUEST[debug]. If $level=0, error is considered fatal. $message will be displayed and program exectution will be halted. |
$Id: index.htm,v 1.4 2003/02/25 03:44:27 csnyder Exp $