Class Model

Description

Abstract superclass of MemModel and DbModel. A model is a programming interface to an RDF graph.

An RDF graph is a directed labeled graph, as described in http://www.w3.org/TR/rdf-mt/. It can be defined as a set of <S, P, O> triples, where P is a uriref, S is either a uriref or a blank node, and O is either a uriref, a blank node, or a literal.

  • author: Radoslaw Oldakowski <radol@gmx.de>
  • author: Daniel Westphal <mail@d-westphal.de>
  • version: $Id: Model.html 443 2007-06-01 16:25:38Z cax $
  • access: public

Located in /model/Model.php (line 21)

Object
   |
   --Model
Direct descendents
Class Description
DbModel This class provides methods for manipulating DbModels from DbStore.
MemModel A MemModel is an RDF Model, which is stored in the main memory.
Variable Summary
Parser $queryParser
Method Summary
Model Model ()
object MemModel findForward (object Node $subject, object Node $predicate, object MemModel $object, [ &$newModel = NULL])
string getBaseURI ()
object MemModel &getMemModelByRDQL (string $queryString, [boolean $closure = FALSE])
object OntModel &getOntModel (constant $vocabulary)
object ResModel &getResModel ()
void load (string $filename, [string $type = NULL], [boolean $stream = false])
string/array sparqlQuery (string $query, [string $resultform = false])
string, visualize ([string $format = "dot"], [boolean $short_prefix = TRUE])
Query _parseSparqlQuery ($query $query)
array _prepareSparql ()
Variables
Parser $queryParser = null (line 44)

SparqlParser so we can re-use it

Methods
Constructor Model (line 54)

Notice for people who are used to work with older versions of RAP.

  • throws: PHPError
  • access: public
Model Model ()
findForward (line 265)

Searches for triples using find() and tracks forward blank nodes until the final objects in the retrieved subgraphs are all named resources.

The method calls itself recursivly until the result is complete. NULL input for subject, predicate or object will match anything. Inputparameters are ignored for recursivly found statements. Returns a new MemModel or adds (without checking for duplicates) the found statements to a given MemModel. Returns an empty MemModel, if nothing is found. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING: This method can be slow with large models. NOTE: Blank nodes are not renamed, they keep the same nodeIDs as in the queried model! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

object MemModel findForward (object Node $subject, object Node $predicate, object MemModel $object, [ &$newModel = NULL])
getBaseURI (line 71)

Return current baseURI.

  • access: public
string getBaseURI ()
getMemModelByRDQL (line 319)

Perform an RDQL query on this Model. Should work with all types of models.

This method returns a MemModel containing the result statements. If $closure is set to TRUE, the result will additionally contain statements found by the findForward-method for blank nodes. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! WARNING: If called with $closure = TRUE this method can be slow with large models. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • author: code snippets taken from the RAP Netapi by Phil Dawes and Chris Bizer
  • author: Anton K�tlbacher <anton1@koestlbacher.de>
  • access: public
object MemModel &getMemModelByRDQL (string $queryString, [boolean $closure = FALSE])
  • string $queryString
  • boolean $closure
getOntModel (line 234)

Returns an OntModel with this model as baseModel.

$vocabulary has to be one of the following constants (currently only one is supported): RDFS_VOCABULARY to select a RDFS Vocabulary.

This is the same as ModelFactory::getOntModelForBaseModel($this, $vocabulary).

  • access: public
object OntModel &getOntModel (constant $vocabulary)
  • constant $vocabulary
getResModel (line 216)

Returns a ResModel with this model as baseModel. This is the same as ModelFactory::getResModelForBaseModel($this).

  • access: public
object ResModel &getResModel ()
load (line 89)

Load a model from a file containing RDF, N3, N-Triples or a xhtml document containing RDF.

This function recognizes the suffix of the filename (.n3 or .rdf) and calls a suitable parser, if no $type is given as string ("rdf" "n3" "nt"); If the model is not empty, the contents of the file is added to this DbModel.

  • access: public
void load (string $filename, [string $type = NULL], [boolean $stream = false])
  • string $filename
  • string $type
  • boolean $stream

Redefined in descendants as:
sparqlPrepare (line 469)

Prepares a sparql query and returns a prepared statement that can be executed with data later on.

  • return: prepared statement object
SparqlEngine_PreparedStatement sparqlPrepare (string $query)
  • string $query: Sparql query to prepare.
sparqlQuery (line 450)

Performs a SPARQL query against a model. The model is converted to an RDF Dataset. The result can be retrived in SPARQL Query Results XML Format or as an array containing the variables an their bindings.

string/array sparqlQuery (string $query, [string $resultform = false])
  • string $query: the sparql query string
  • string $resultform: the result form ('xml' for SPARQL Query Results XML Format)
visualize (line 435)

Alias for RDFUtil::visualiseGraph(&$model, $format, $short_prefix)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Note: See RDFUtil for further Information. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

string, visualize ([string $format = "dot"], [boolean $short_prefix = TRUE])
  • string $format
  • boolean $short_prefix
_parseSparqlQuery (line 512)

Parses an query and returns the parsed form.

If the query is not a string but a Query object, it will just be returned.

  • return: query object
  • throws: Exception If $query is no string and no Query object
Query _parseSparqlQuery ($query $query)
  • $query $query: mixed String or Query object
_prepareSparql (line 487)

Prepares everything for SparqlEngine-usage Loads the files, creates instances for SparqlEngine and Dataset...

  • return: First value is the sparql engine, second the dataset
array _prepareSparql ()

Inherited Methods

Inherited From Object

Object::toString()

Documentation generated on Fri, 1 Jun 2007 16:49:52 +0200 by phpDocumentor 1.3.2