コード例 #1
0
ファイル: custom_test2.php プロジェクト: richardjennings/rap
 // Process RDF
 // (if submitted and RDF smaller than 10000 chars)
 /////////////////////////////////////////////////////////////////
 define("RDFAPI_INCLUDE_DIR", "../api/");
 include RDFAPI_INCLUDE_DIR . "RdfAPI.php";
 include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
 include_once RDFAPI_INCLUDE_DIR . PACKAGE_UTILITY;
 // Prepare RDF
 $rdfInput = stripslashes($_POST['RDF']);
 // Show the submitted RDF
 echo "<BR><H3>Your original RDF input:</h3><BR>";
 echo_string_with_linenumbers($rdfInput);
 // Create a new MemModel
 //$model = new MemModel();
 // Load and parse document
 $parser = new RdfParser();
 // Set the base URI of the model
 //$model->setBaseURI("http://www3.wiwiss.fu-berlin.de/DemoModel#");
 $rdfBaseURI = 'http://www.wiwiss.fu-berlin.de/suhl/bizer/resource02.rdf';
 $model =& $parser->generateModel($rdfInput, $rdfBaseURI);
 // Execute query on model if submitted
 if ($_POST['query_subject'] != '' or $_POST['query_predicate'] != '' or $_POST['query_object'] != '') {
     $comment_string = "<BR><H3>The following query has been executed:</H3><BR>";
     $query_subj = NULL;
     $query_pred = NULL;
     $query_obj = NULL;
     if ($_POST['query_subject'] != '') {
         if ($_POST['subject_kind'] == 'resource') {
             $query_subj = new Resource($_POST['query_subject']);
         } else {
             $query_subj = new BlankNode($_POST['query_subject']);
コード例 #2
0
ファイル: GRDDLParser.php プロジェクト: VUW-SIM-FIS/emiemi
 function _generateRDF()
 {
     $model = new MemModel();
     $model->setBaseURI($this->doclink);
     $proc = new xsltprocessor();
     include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
     $pars = new RdfParser();
     foreach ($this->stylelink as $key => $value) {
         $xsl = new DomDocument();
         $xsl->load($value);
         $proc->importStyleSheet($xsl);
         $model->addModel($pars->generateModel($proc->transformToXML($this->domdoc), $this->doclink));
     }
     return $model;
 }
コード例 #3
0
ファイル: SparqlClient.php プロジェクト: VUW-SIM-FIS/emiemi
 /**
  * Returns the query result.
  *
  * @param String  $result  the result.
  * @return mixed
  */
 function returnResult($result)
 {
     if (strpos($result, "<rdf:RDF")) {
         include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
         $parser = new RdfParser();
         return $parser->generateModel(substr($result, strpos($result, "<rdf:RDF")));
     }
     if ($this->output == "xml") {
         $pos = strpos($result, "<?xml");
         return substr($result, $pos);
     }
     if ($this->output == "array") {
         //	$pos = strpos($buffer,"<?xml");
         return $this->parseResult($result);
     }
     return $result;
 }
コード例 #4
0
ファイル: Model.php プロジェクト: p4535992/programate
 /**
  * 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.
  *
  * @param 	string 	$filename
  * @param 	string 	$type
  * @param   boolean $stream
  * @access	public
  */
 function load($filename, $type = NULL, $stream = false)
 {
     if (isset($type) && $type == 'n3' or $type == 'nt') {
         // Import Package Syntax
         include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_N3;
         $parser = new N3Parser();
     } elseif (isset($type) && $type == 'rdf') {
         // Import Package Syntax
         include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
         $parser = new RdfParser();
     } elseif (isset($type) && $type == 'grddl') {
         // Import Package Syntax
         include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_GRDDL;
         $parser = new GRDDLParser();
     } elseif (isset($type) && $type == 'rss') {
         // Import Package Syntax
         include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RSS;
         $parser = new RssParser();
     } else {
         // create a parser according to the suffix of the filename
         // if there is no suffix assume the file to be XML/RDF
         preg_match("/\\.([a-zA-Z0-9_]+)\$/", $filename, $suffix);
         if (isset($suffix[1]) && (strtolower($suffix[1]) == 'n3' or strtolower($suffix[1]) == 'nt')) {
             // Import Package Syntax
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_N3;
             $parser = new N3Parser();
         } elseif (isset($suffix[1]) && (strtolower($suffix[1]) == 'htm' or strtolower($suffix[1]) == 'html' or strtolower($suffix[1]) == 'xhtml')) {
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_GRDDL;
             $parser = new GRDDLParser();
         } else {
             // Import Package Syntax
             include_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
             $parser = new RdfParser();
         }
     }
     if ($stream && $type == 'rdf' || $stream && $type == 'n3') {
         $temp =& $parser->generateModel($filename, false, $this);
     } else {
         $temp =& $parser->generateModel($filename);
     }
     $this->addModel($temp);
     if ($this->getBaseURI() == null) {
         $this->setBaseURI($temp->getBaseURI());
     }
 }
コード例 #5
0
ファイル: add.php プロジェクト: komagata/plnet
     $m->addModel($m2);
     print "Read " . $_FILES["rdffile"]["size"] . " bytes and " . count($m2->triples) . " triples.<br/></p>\n";
 }
 if (isset($_REQUEST["rdfuri"])) {
     $u = $_REQUEST["rdfuri"];
     print "<h1>Downloading {$u}</h1>\n";
     if (isset($PROXYHOST)) {
         $a = getthroughproxy($u, $PROXYHOST, $PROXYPORT);
         $f = tempnam();
         $fp = fopen($f);
         fputs($fp, $a["content"]);
         fclose($fp);
     } else {
         $f = $u;
     }
     $ri = new RdfParser();
     $m2 = $ri->generateModel($f);
     $m->addModel($m2);
     print "Read " . count($m2->triples) . " triples.</br></p>\n";
 }
 if (isset($_REQUEST["tripleadd"])) {
     print "<h1>Adding...</h1>\n";
     if (isset($_REQUEST["bnode"])) {
         $s = $_REQUEST["subject"] != "" ? new BlankNode($_REQUEST["subject"]) : null;
     } else {
         $s = $_REQUEST["subject"] != "" ? new Resource($_REQUEST["subject"]) : null;
     }
     $p = $_REQUEST["predicate"] != "" ? new Resource($_REQUEST["predicate"]) : null;
     if (isset($_REQUEST["literal"])) {
         $o = $_REQUEST["object"] != "" ? new Literal($_REQUEST["object"]) : null;
     } else {
コード例 #6
0
<?php

require dirname(__FILE__) . "/../../rdfphp-api/api/RdfPHP.php";
if (!defined("RSS_FILE")) {
    define("RSS_FILE", "recentchanges.rss");
}
$parser = new RdfParser();
$model = $parser->generateModel(RSS_FILE);
$rdql_query = '
		SELECT ?givenName, ?age
		WHERE 
			(?x, <v:age>, ?age),
			(?x, <vcard:N>, ?blank),
			(?blank, <vcard:Given>, ?givenName)
		USING 
			vcard FOR <http://www.w3.org/2001/vcard-rdf/3.0#>
			rss FOR <http://purl.org/rss/1.0#>
			v FOR <http://sampleVocabulary.org/1.3/People#>';
// query the model
$res = $model->rdqlQuery($rdql_query);
// show result
RdqlEngine::writeQueryResultAsHtmlTable($res);