function MeducatorParser($rdf, $replace_uri = false) { include_once dirname(__FILE__) . "/meducator_uri_list.php"; $this->results = array(); $this->whereAmI = array(); $this->uri_list = $uri_list; $this->replace_uri = $replace_uri; $parser = new Rdf_parser(); $parser->rdf_parser_create(NULL); $parser->rdf_set_user_data($this); $parser->rdf_set_statement_handler("my_statement_handler"); $parser->rdf_set_warning_handler("my_warning_handler"); $parser->rdf_parse($rdf, strlen($rdf), true); $parser->rdf_parser_free(); $this->deleteDuplicates($this->results); $this->formatData($this->results); //$this->formatIdentifiers($this->results); $this->eliminateEmptyArrays($this->results); $this->formatRights($this->results); $this->formatEducationalObjectives($this->results); $this->eliminateLocalIds($this->results); //print_r($this->results); //$this->renameKeys($this->results); //print_r($this->results); //unset($this->uri_list); }
function MeducatorParser($rdf, $replace_uri = false, $forEdit = false) { include dirname(__FILE__) . "/meducator_uri_list.php"; include dirname(dirname(__FILE__)) . "/views/default/resources/properties_list.php"; $this->results = array(); $this->removed_keys = array(); $this->uri_list = $uri_list; $this->replace_uri = $replace_uri; $this->vocabs = $properties_values; $parser = new Rdf_parser(); $parser->rdf_parser_create(NULL); $parser->rdf_set_user_data($this); $parser->rdf_set_statement_handler("my_statement_handler_parser"); $parser->rdf_set_warning_handler("my_warning_handler_parser"); $parser->rdf_parse($rdf, strlen($rdf), true); $parser->rdf_parser_free(); $this->deleteDuplicates($this->results); $this->formatData($this->results); $this->eliminateEmptyArrays($this->results); // print_r($this->results); $this->formatEducationalObjectives($this->results); $this->eliminateLocalIds($this->results); $this->formatIdentifiers($this->results); if ($forEdit == false) { $this->formatVocabularies($this->results); } unset($this->removed_keys); //$this->renameKeys($this->results); //print_r($this->vocabs); //print_r($this->results); //unset($this->uri_list); }
function parse_install_manifest($manifestdata) { $data = array(); $rdf = new Rdf_parser(); $rdf->rdf_parser_create(NULL); $rdf->rdf_set_user_data($data); $rdf->rdf_set_statement_handler("mf_statement_handler"); $rdf->rdf_set_base(""); if (!$rdf->rdf_parse($manifestdata, strlen($manifestdata), true)) { return null; } // now set the targetApplication data for real $tarray = array(); if (is_array($data["manifest"]["targetApplication"])) { foreach ($data["manifest"]["targetApplication"] as $ta) { $id = $data[$ta][EM_NS . "id"]; $minVer = $data[$ta][EM_NS . "minVersion"]; $maxVer = $data[$ta][EM_NS . "maxVersion"]; $tarray[$id]["minVersion"] = $minVer; $tarray[$id]["maxVersion"] = $maxVer; } } $data["manifest"]["targetApplication"] = $tarray; $rdf->rdf_parser_free(); return $data["manifest"]; }
function ServicesParser($rdf) { $this->results = array(); $parser = new Rdf_parser(); $parser->rdf_parser_create(NULL); $parser->rdf_set_user_data($this); $parser->rdf_set_statement_handler("my_services_statement_handler"); $parser->rdf_parse($rdf, strlen($rdf), true); $parser->rdf_parser_free(); }
function getVocabularyData($vocabularyFile) { $rdf = file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/repository/vocabularies/" . $vocabularyFile); $data = array(); $parser = new Rdf_parser(); $parser->rdf_parser_create(NULL); $parser->rdf_set_user_data($data); $parser->rdf_set_statement_handler("my_statement_handler"); $parser->rdf_parse($rdf, strlen($rdf), true); $parser->rdf_parser_free(); asort($data); return $data; }
/** * Sends the RDF response to the RDF parser object. * @access private */ function mbrainz_RDF_parse($rawRdf) { $parser = new Rdf_parser(); $parser->rdf_parser_create(NULL); $parser->rdf_set_statement_handler('mbrainz_RDF_handler'); $parser->rdf_set_base(''); $parser->rdf_set_user_data($results); $status = $parser->rdf_parse($rawRdf, strlen($rawRdf), TRUE); $parser->rdf_parser_free(); if ($status) { return mbrainz_build_result_array($results); } else { return FALSE; } }
function getVocabularyData($vocabularyFile) { $rdf = file_get_contents(dirname(dirname(dirname(dirname(__FILE__)))) . "/repository/vocabularies/" . $vocabularyFile); $data = array(); $data["values"] = array(); $data["map"] = array(); $data["map"]["http://www.w3.org/2000/01/rdf-schema#label"] = "label"; $data["map"]["http://www.w3.org/2004/02/skos/core#prefLabel"] = "prefLabel"; $data["map"]["http://www.w3.org/2004/02/skos/core#narrower"] = "narrower"; $parser = new Rdf_parser(); $parser->rdf_parser_create(NULL); $parser->rdf_set_user_data($data); $parser->rdf_set_statement_handler("my_statement_handler_vocabs"); $parser->rdf_parse($rdf, strlen($rdf), true); $parser->rdf_parser_free(); $data = $data["values"]; //print_r($data); return $data; }
function rss_parse_data($data) { $rdf = new Rdf_parser(); $rdf->rdf_parser_create(NULL); $rdf->rdf_set_user_data($statements); // Here we'd have to use a rdf_set_object and then call the object method if set... $rdf->rdf_set_user_data($this); $rdf->rdf_set_statement_handler("my_statement_handler"); $rdf->rdf_set_warning_handler("my_warning_handler"); $rdf->rdf_set_base(''); $done = false; if (!$rdf->rdf_parse($data, strlen($data), true)) { printf("**** ERROR **** : %s at line %s", print xml_get_error_code($rdf->rdf_get_xml_parser()), print xml_get_current_line_number($rdf->rdf_get_xml_parser())); return false; } $rdf->rdf_parser_free(); return true; }
function rss_parse($rss) { $base = $rss; //get XML content $xmlResponse = ''; //get RSS Content $ch = curl_init(); /// initialize a cURL session curl_setopt($ch, CURLOPT_URL, trim($rss)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $xmlResponse = curl_exec($ch); curl_close($ch); //check result if (!is_string($xmlResponse) || !strlen($xmlResponse)) { $this->errorText .= '<span class="' . $this->CssContentStyle . '">Cannot open RSS URL ' . trim($rss) . '</span>'; return false; } $rdf = new Rdf_parser(); $rdf->rdf_parser_create(NULL); $rdf->rdf_set_user_data($statements); // Here we'd have to use a rdf_set_object and then call the object method if set... $rdf->rdf_set_user_data($this); $rdf->rdf_set_statement_handler("my_statement_handler"); $rdf->rdf_set_warning_handler("my_warning_handler"); $rdf->rdf_set_base($base); if (!$rdf->rdf_parse($xmlResponse, strlen($xmlResponse), 0)) { $this->errorText = 'Error <' . xml_get_error_code($rdf->rdf_get_xml_parser()) . '> at line ' . xml_get_current_line_number($rdf->rdf_get_xml_parser()); return false; } $rdf->rdf_parser_free(); return true; }
<?php include_once "class_rdf_parser.php"; /* This is the URI of the document to be dumped: */ $base = "http://www.w3.org/2000/10/rdf-tests/RSS_1.0/rss_5.3_1.rdf"; //$base="resource-01.rdf"; /* RDF Parser Handler functions are defined below this code */ $statements = 0; $input = fopen($base, "r"); $rdf = new Rdf_parser(); $rdf->rdf_parser_create(NULL); $rdf->rdf_set_user_data($statements); $rdf->rdf_set_statement_handler("my_statement_handler"); $rdf->rdf_set_parse_type_literal_handler("my_start_parse_type_literal_handler", "my_end_parse_type_literal_handler"); $rdf->rdf_set_element_handler("my_start_element_handler", "my_end_element_handler"); $rdf->rdf_set_character_data_handler("my_character_data_handler"); $rdf->rdf_set_warning_handler("my_warning_handler"); $rdf->rdf_set_base($base); $done = false; while (!$done) { $buf = fread($input, 512); $done = feof($input); if (!$rdf->rdf_parse($buf, strlen($buf), feof($input))) { printf("**** ERROR **** : %s at line %s", print xml_get_error_code($rdf->rdf_get_xml_parser()), print xml_get_current_line_number($rdf->rdf_get_xml_parser())); return 1; } } /* close file. */ fclose($input); $rdf->rdf_parser_free(); printf("Total statements: " . $statements);