function _rdfx_parse_rdf in RDF Extensions 7.2
1 call to _rdfx_parse_rdf()
- rdfx_fetch_rdf in ./
rdfx.import.inc - Loads an RDF file from an HTTP URI or local file, parses it, and builds an RDF schema representation (associative array) from it.
File
- ./
rdfx.import.inc, line 39 - Functions for importing and parsing RDF data.
Code
function _rdfx_parse_rdf($base_uri) {
$namespaces = array();
$parser = ARC2::getRDFParser();
$parser
->parse($base_uri);
// If this is an N3 file, the namespaces array isn't populated. Iterate
// through the attached parser object's prefixes and remove the colon from
// the end of the prefix.
// @todo File an issue with ARC2.
switch ($parser->format) {
case 'turtle':
foreach ($parser->parser->prefixes as $prefix => $uri) {
$formatted_prefix = str_replace(':', '', $prefix);
$namespaces[$formatted_prefix] = $uri;
}
break;
default:
foreach ($parser->parser->nsp as $uri => $prefix) {
$namespaces[$prefix] = $uri;
}
break;
}
return array(
$parser
->getTriples(),
$namespaces,
);
}