Source for file Query.php
Documentation is available at Query.php
require_once RDFAPI_INCLUDE_DIR .
'sparql/GraphPattern.php';
* The Class Query represents a SPARQL query.
* @author Tobias Gauss <tobias.gauss@web.de>
* @version $Id: fsource_sparql__sparqlQuery.php.html 443 2007-06-01 16:25:38Z cax $
* The BASE part of the SPARQL query.
* Array that contains used prefixes and namespaces.
* Key is the prefix, value the namespace.
* ["rdf"] => string(43) "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
* ["rdfs"]=> string(37) "http://www.w3.org/2000/01/rdf-schema#"
* Array of result variables that shall be returned.
* What form/type of result should be returned.
* @see http://www.w3.org/TR/rdf-sparql-query/#QueryForms
* Contains the result part of the SPARQL query.
* Contains the FROM part of the SPARQL query.
* Contains the FROM NAMED part of the SPARQL query.
* Optional solution modifier of the query.
* "order by", "limit", "offset"
* If they are not set, their value is null
* "order by" can be an array with subarrays, each of those
* subarrays having two keys: "val" and "type".
* "val" determines the variable ("?mbox"), "type" is
* How many blank nodes are in $resultPart
* How many GraphPattern are in $resultPart
* List of all vars used in the query.
* Key is the variable (e.g. "?x"), value
* If the query type is CONSTRUCT this variable contains the
* CONSTRUCT graph pattern.
* TRUE if the query is empty FALSE if not.
* Language of variables. NULL if the variable has no
* language tag (e.g. @en) set.
* $varname => $language tag
* Datatype of variables. NULL if the variable has no
* data type (e.g. ^^xsd::integer) set.
* Returns the BASE part of the query.
* Returns the prefix map of the query.
* Returns a list containing the result vars.
* Returns the type the result shall have.
* E.g. "select", "select distinct", "ask", ...
* Returns a list containing the graph patterns of the query.
* Returns the FROM clause of the query.
* Returns the FROM NAMED clause of the query.
* Returns $isEmpty variable
* Returns an unused Bnode label.
* Adds a prefix to the list of prefixes.
* Adds a variable to the list of result variables.
* Adds a graph pattern to the result part.
* @param GraphPattern $pattern
* Adds a construct graph pattern to the query.
* @param GraphPattern $pattern
* Adds a graphuri to the from part.
* @param String $graphURI
public function addFrom($graphURI){
* Adds a graphuri to the from named part.
* @param String $graphURI
* Sets a solution modifier.
* Generates a new GraphPattern. If it is a CONSTRUCT graph pattern
* $constr has to set to TRUE, FALSE if not.
* Adds a new variable to the variable list.
* Returns a list with all used variables.
* Gets the solution modifiers of the query.
* $solutionModifier['order by'] = value
* Returns the construvtGraphPattern of the query if there is one.
* Returns a list of variables used in the construct patterns.
* @return array Array of variable names, unique.
if (count($this->resultPart) > 0) {
foreach ($this->resultPart as $pattern) {
$arVars = array_merge($arVars, $pattern->getVariables());
}//public function getConstructPatternVariables()
* Returns the language of a variable if the tag is set (e.g. @en)
* Returns NULL if no language is set.
* @param string Sparql variable name
* @return mixed NULL or language tag
//in case @ and ^^ are combined
$nHatHat =
strpos($var, '^^', $nAt +
1);
if ($nHatHat ===
false) {
$tag =
substr($var, $nAt +
1);
$tag =
substr($var, $nAt +
1, $nHatHat -
$nAt -
1);
}//public static function getLanguageTag($var)
* Returns the datatype of a variable if it is set.
* @param string Sparql variable name
* @return mixed NULL or datatype
$nHatHat =
strpos($var, '^^');
if ($nHatHat ===
false) {
$nAt =
strpos($var, '@', $nHatHat +
2);
$type =
substr($var, $nHatHat +
2);
$type =
substr($var, $nHatHat +
2, $nAt -
$nHatHat -
2);
if ($fullUri ===
false) {
if ($fullUri[0] ==
'<' &&
substr($fullUri, -
1) ==
'>') {
$fullUri =
substr($fullUri, 1, -
1);
}//public function getDatatype($var)
* Gets the full URI of a qname token.
* @return string The complete URI of a given token, false if $token is not
* a qname or the prefix is not defined
$pattern=
"/^([^:]*):([^:]*)$/";
Documentation generated on Fri, 1 Jun 2007 16:50:27 +0200 by phpDocumentor 1.3.2