public function serialize(&$return = null, $format = 'xml') { $CI =& get_instance(); if ('object' != gettype($CI->rdf_store)) { $CI->load->library('RDF_Store', 'rdf_store'); } $output = array(); if (!empty($return)) { foreach ($return as $key => $row) { foreach ($row as $field => $value) { if ('@' == substr($field, 0, 1)) { continue; } $output[$key][fromNS($field, $this->ns)] = $value; } } } $return = $CI->rdf_store->serialize($output, '', $format); // by reference return $return; // by value }
/** * Serialize an RDF structure (e.g, to RDF-XML or RDF-JSON) * TODO: Shared function with /rdf, move to model? */ private function _rdf_serialize(&$return, $prefix = '') { if (empty($return)) { $this->_output_error(StatusCodes::HTTP_INTERNAL_SERVER_ERROR); } $output = array(); foreach ($return as $key => $row) { foreach ($row as $field => $value) { if (substr($field, 0, 1) == '@') { continue; } $output[$key][fromNS($field, $this->ns)] = $value; } } $return = $this->rdf_store->serialize($output, $prefix, $this->data['format']); }