public function toRDF($input, $options) {
    global $jsonld_default_load_document;
    self::setdefaults($options, array(
      'base' => is_string($input) ? $input : '',
      'produceGeneralizedRdf' => false,
      'documentLoader' => $jsonld_default_load_document));

    try {
      // expand input
      $expanded = $this->expand($input, $options);
    } catch(JsonLdException $e) {
      throw new JsonLdException(
        'Could not expand input before serialization to RDF.',
        'jsonld.RdfError', null, null, $e);
    }

    // create node map for default graph (and any named graphs)
    $namer = new UniqueNamer('_:b');
    $node_map = (object)array('@default' => new stdClass());
    $this->_createNodeMap($expanded, $node_map, '@default', $namer);

    // output RDF dataset
    $dataset = new stdClass();
    $graph_names = array_keys((array)$node_map);
    sort($graph_names);
    foreach($graph_names as $graph_name) {
      $graph = $node_map->{$graph_name};
      // skip relative IRIs
      if($graph_name === '@default' || self::_isAbsoluteIri($graph_name)) {
        $dataset->{$graph_name} = $this->_graphToRDF($graph, $namer, $options);
      }
    }

    $rval = $dataset;

    // convert to output format
    if(isset($options['format']) && $options['format']) {
      // supported formats
      if($options['format'] === 'application/nquads') {
        $rval = self::toNQuads($dataset);
      } else {
        throw new JsonLdException(
          'Unknown output format.', 'jsonld.UnknownFormat',
          null, array('format' => $options['format']));
      }
    }

    return $rval;
  }
public function toRDF($input, $options) {
    global $jsonld_default_load_document;
    self::setdefaults($options, array(
      'base' => is_string($input) ? $input : '',
      'produceGeneralizedRdf' => false,
      'documentLoader' => $jsonld_default_load_document));

    try {
      // expand input
      $expanded = $this->expand($input, $options);
    } catch(JsonLdException $e) {
      throw new JsonLdException(
        'Could not expand input before serialization to RDF.',
        'jsonld.RdfError', null, null, $e);
    }

    // create node map for default graph (and any named graphs)
    $namer = new UniqueNamer('_:b');
    $node_map = (object)array('@default' => new stdClass());
    $this->_createNodeMap($expanded, $node_map, '@default', $namer);

    // output RDF dataset
    $dataset = new stdClass();
    $graph_names = array_keys((array)$node_map);
    sort($graph_names);
    foreach($graph_names as $graph_name) {
      $graph = $node_map->{$graph_name};
      // skip relative IRIs
      if($graph_name === '@default' || self::_isAbsoluteIri($graph_name)) {
        $dataset->{$graph_name} = $this->_graphToRDF($graph, $namer, $options);
      }
    }

    $rval = $dataset;

    // convert to output format
    if(isset($options['format']) && $options['format']) {
      // supported formats
      if($options['format'] === 'application/nquads') {
        $rval = self::toNQuads($dataset);
      } else {
        throw new JsonLdException(
          'Unknown output format.', 'jsonld.UnknownFormat',
          null, array('format' => $options['format']));
      }
    }

    return $rval;
  }
public function toRDF ( $ input , $ options ) { global $ jsonld_default_load_document ; self :: setdefaults ( $ options , array ( 'base' => is_string ( $ input ) ? $ input : '' , 'produceGeneralizedRdf' => false , 'documentLoader' => $ jsonld_default_load_document ) ) ; try { // expand input $ expanded = $ this -> expand ( $ input , $ options ) ; } catch ( JsonLdException $ e ) { throw new JsonLdException ( 'Could not expand input before serialization to RDF.' , 'jsonld.RdfError' , null , null , $ e ) ; } // create node map for default graph (and any named graphs) $ namer = new UniqueNamer ( '_:b' ) ; $ node_map = ( object ) array ( '@default' => new stdClass ( ) ) ; $ this -> _createNodeMap ( $ expanded , $ node_map , '@default' , $ namer ) ; // output RDF dataset $ dataset = new stdClass ( ) ; $ graph_names = array_keys ( ( array ) $ node_map ) ; sort ( $ graph_names ) ; foreach ( $ graph_names as $ graph_name ) { $ graph = $ node_map -> { $ graph_name } ; // skip relative IRIs if ( $ graph_name === '@default' || self :: _isAbsoluteIri ( $ graph_name ) ) { $ dataset -> { $ graph_name } = $ this -> _graphToRDF ( $ graph , $ namer , $ options ) ; } } $ rval = $ dataset ; // convert to output format if ( isset ( $ options [ 'format' ] ) && $ options [ 'format' ] ) { // supported formats if ( $ options [ 'format' ] === 'application/nquads' ) { $ rval = self :: toNQuads ( $ dataset ) ; } else { throw new JsonLdException ( 'Unknown output format.' , 'jsonld.UnknownFormat' , null , array ( 'format' => $ options [ 'format' ] ) ) ; } } return $ rval ; }
Outputs the RDF dataset found in the given JSON-LD object.

@param mixed $input the JSON-LD object.
@param assoc $options the options to use:
[base] the base IRI to use.
[expandContext] a context to expand with.
[format] the format to use to output a string:
'application/nquads' for N-Quads.
[produceGeneralizedRdf] true to output generalized RDF, false
to produce only standard RDF (default: false).
[documentLoader(url)] the document loader.

@return mixed the resulting RDF dataset (or a serialization of it).
Outputs the RDF dataset found in the given JSON - LD object .