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);
 }
Пример #3
0
 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;
 }
Пример #5
0
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);
/* handlers */