Class SparqlEngine

Description

This engine executes SPARQL queries against an RDF Datatset.

  • author: Tobias Gauß <tobias.gauss@web.de>
  • version: $Id: SparqlEngine.html,v 1.9 2006/06/26 12:34:21 tgauss Exp $

Located in /sparql/SparqlEngine.php (line 16)

Object
   |
   --SparqlEngine
Method Summary
Array buildVarmap (String $order, Array $vartable)
String buildXmlResult (mixed $vartable)
boolean checkIntBindings (Triple $trip, Array $intBindings)
MemModel constructGraph (Array $vartable, GraphPattern $constructPattern)
MemModel describeGraph (Array $vartable)
Array distinct (Array $vartable)
String fillConstraintString (Array $vars, Array $res, Constraint $constraint, Array $function)
Array filterPatterns (Array $patternlist, boolean $outer)
Array findTuplesMatchingOnePattern (TriplePattern $pattern, Array $graphlist)
Array joinOptionalTuples (Array &$finalRes, Array &$res)
Array joinResults (Array $patternlist)
Array joinTuples (Array &$finalRes, Array &$res)
void matchPattern ( &$patternlist, array $graphlist,  &$graphPattern, Array $patternlist, GraphPattern $graphPattern)
Array matchPatterns (Array $graphlist)
Array preselectGraphs ()
Array/String queryModel (Dataset $dataset, Query $query, [String $resultform = false])
Array/String returnResult (Array $vartable, [String/boolean $resultform = false])
Array selectVars (Array $table, Array $vars)
Array sortVars (Array $vartable)
void writeQueryResultAsHtmlTable (array $queryResult)
Array _buildIntBindings (Array $var)
Array _buildResultSet (GraphPattern $pattern, Array $resmodel)
Array _checkGraphs ( &$pattern, Array $graphlist, GraphPattern $pattern)
String _determineType (Node $var, MemModel $resultGraph)
void _getAttributes (Array $list, MemModel $resultGraph,  $varvalue)
String _getBindingString (String $varname, Node $varvalue)
Methods
buildVarmap (line 933)

Sorts the result table.

  • return: A map that contains the new order of the result vars
Array buildVarmap (String $order, Array $vartable)
  • String $order: (ASC/DESC)
  • Array $vartable: the vartable
buildXmlResult (line 1219)

Generates an xml string from a given result table.

  • return: The xml result string
String buildXmlResult (mixed $vartable)
checkIntBindings (line 244)

Checks it there are internal bindings between variables.

boolean checkIntBindings (Triple $trip, Array $intBindings)
  • Triple $trip
  • Array $intBindings
constructGraph (line 1004)

Constructs a result graph.

  • return: the result graph which matches the CONSTRUCT pattern
MemModel constructGraph (Array $vartable, GraphPattern $constructPattern)
  • Array $vartable: a table containing the result vars and their bindings
  • GraphPattern $constructPattern: the CONSTRUCT pattern
describeGraph (line 1051)

Builds a describing named graph. To define an attribute list for a several rdf:type look at constants.php

MemModel describeGraph (Array $vartable)
  • Array $vartable
distinct (line 1153)

Eliminates duplicate results.

  • return: the result table without duplicate results
Array distinct (Array $vartable)
  • Array $vartable: a table that contains the result vars and their bindings
fillConstraintString (line 696)

Builds an evaluation string to determine wether the result passes the filter or not. This string is evaluatet by the php buildin eval() function

String fillConstraintString (Array $vars, Array $res, Constraint $constraint, Array $function)
  • Array $vars: a list which contains the used variables
  • Array $res: the result part which have to be evaluated
  • Constraint $constraint: the Constrain object
  • Array $function: an Array which contains the used functions
filterPatterns (line 601)

Filters the pattern results.

  • return: the filtered patternlist
Array filterPatterns (Array $patternlist, boolean $outer)
  • Array $patternlist: list containing the results of the GraphPatterns
  • boolean $outer: TRUE if its an outer filter FALSE if not
findTuplesMatchingOnePattern (line 156)

Finds Tuples matching one TriplePattern.

Array findTuplesMatchingOnePattern (TriplePattern $pattern, Array $graphlist)
  • TriplePattern $pattern
  • Array $graphlist
joinOptionalTuples (line 346)

Joins OPTIONAL pattern results.

  • return: the joined Array
Array joinOptionalTuples (Array &$finalRes, Array &$res)
  • Array &$finalRes
  • Array &$res
joinResults (line 554)

Joins the results of the different Graphpatterns.

Array joinResults (Array $patternlist)
  • Array $patternlist
joinTuples (line 283)

Perform an SQL-like inner join on two resultSets.

Array joinTuples (Array &$finalRes, Array &$res)
  • Array &$finalRes
  • Array &$res
matchPattern (line 92)

Finds tuples that match one graph pattern.

void matchPattern ( &$patternlist, array $graphlist,  &$graphPattern, Array $patternlist, GraphPattern $graphPattern)
  • Array $patternlist: list that contains the graphPatterns
  • array $graphlist: the graphlist
  • GraphPattern $graphPattern: the pattern which has to be matched
  • &$patternlist
  • &$graphPattern
matchPatterns (line 71)

Matches all graph Patterns against the dataset and generates an array which contains the result sets for every given GraphPattern.

Array matchPatterns (Array $graphlist)
  • Array $graphlist: the graphlist which contains the names of the named graphs which has to be queried.
preselectGraphs (line 416)

Looks in from and from named part of the query and adds the graphs to the graphlist.

Array preselectGraphs ()
queryModel (line 40)

The query engines main method.

  • return: Type of the result depends on $resultform.
Array/String queryModel (Dataset $dataset, Query $query, [String $resultform = false])
  • Dataset $dataset: the RDF Dataset
  • Query $query: the parsed SPARQL query
  • String $resultform: the result form. If set to 'xml' the result will be SPARQL Query Results XML Format as described in http://www.w3.org/TR/rdf-sparql-XMLres/ .
returnResult (line 1176)

Generates the result object.

  • return: The result
Array/String returnResult (Array $vartable, [String/boolean $resultform = false])
  • Array $vartable: The result table
  • String/boolean $resultform: If set to 'xml' the result will be SPARQL Query Results XML Format as described in http://www.w3.org/TR/rdf-sparql-XMLres/
selectVars (line 530)

Selects the result variables and builds a result table.

Array selectVars (Array $table, Array $vars)
  • Array $table: the result table
  • Array $vars: the result variables
sortVars (line 902)

Sorts the results.

  • return: List containing the sorted result vars
Array sortVars (Array $vartable)
  • Array $vartable: List containing the unsorted result vars
writeQueryResultAsHtmlTable (line 1302)

Prints a query result as HTML table.

You can change the colors in the configuration file.

void writeQueryResultAsHtmlTable (array $queryResult)
  • array $queryResult: [][?VARNAME] = object Node
_buildIntBindings (line 460)

Marks triples with internal bindings.

int bindings -1 :none 0:sub=pred 1:sub=obj 2:pred=obj 3:sub=pred=obj.

Array _buildIntBindings (Array $var)
  • Array $var
_buildResultSet (line 493)

Builds the resultset.

Array _buildResultSet (GraphPattern $pattern, Array $resmodel)
_checkGraphs (line 433)

Evaluates the GRPAH clause if there is one. Checks if the GRAPH clause contains an IRI, variable or nothing.

Returns an array which contains the graphs that has to be matched.

Array _checkGraphs ( &$pattern, Array $graphlist, GraphPattern $pattern)
_determineType (line 1091)

Tries to determine the rdf:type of the variable.

  • return: Uri of the rdf:type
String _determineType (Node $var, MemModel $resultGraph)
  • Node $var: The variable
  • MemModel $resultGraph: The result graph which describes the Resource
_getAttributes (line 1126)

Search the attributes listed in $list in the dataset.

void _getAttributes (Array $list, MemModel $resultGraph,  $varvalue)
  • Array $list: List containing the attributes
  • MemModel $resultGraph: The result graph which describes the Resource
  • $varvalue
_getBindingString (line 1273)

Helper Function for function buildXmlResult($vartable). Generates an xml string for a single variable an their corresponding value.

  • return: The xml string
String _getBindingString (String $varname, Node $varvalue)
  • String $varname: The variables name
  • Node $varvalue: The value of the variable

Inherited Methods

Inherited From Object

Object::toString()

Documentation generated on Mon, 26 Jun 2006 14:26:16 +0200 by phpDocumentor 1.3.0RC6