getSer() static public method

* serializers
static public getSer ( $prefix, $a = '' )
Example #1
0
 /**
  * Serialise an EasyRdf\Graph into RDF format of choice.
  *
  * @param Graph  $graph   An EasyRdf\Graph object.
  * @param string $format  The name of the format to convert to.
  * @param array  $options
  *
  * @throws Exception
  *
  * @return string              The RDF in the new desired format.
  */
 public function serialise($graph, $format, array $options = array())
 {
     parent::checkSerialiseParams($graph, $format);
     if (array_key_exists($format, self::$supportedTypes)) {
         $className = self::$supportedTypes[$format];
     } else {
         throw new Exception("EasyRdf\\Serialiser\\Arc does not support: {$format}");
     }
     $serialiser = \ARC2::getSer($className);
     if ($serialiser) {
         return $serialiser->getSerializedIndex(parent::serialise($graph, 'php'));
     } else {
         throw new Exception("ARC2 failed to get a {$className} serialiser.");
     }
 }
Example #2
0
 /**
  * Serialise an EasyRdf_Graph into RDF format of choice.
  *
  * @param string  $graph   An EasyRdf_Graph object.
  * @param string  $format  The name of the format to convert to.
  * @return string          The RDF in the new desired format.
  */
 public function serialise($graph, $format)
 {
     parent::checkSerialiseParams($graph, $format);
     if (array_key_exists($format, self::$_supportedTypes)) {
         $className = self::$_supportedTypes[$format];
     } else {
         throw new EasyRdf_Exception("Serialising documents to {$format} " . "is not supported by EasyRdf_Serialiser_Arc.");
     }
     $serialiser = ARC2::getSer($className);
     if ($serialiser) {
         return $serialiser->getSerializedIndex(parent::serialise($graph, 'php'));
     } else {
         throw new EasyRdf_Exception("ARC2 failed to get a {$className} serialiser.");
     }
 }
Example #3
0
 function getPOSHRDFSerializer($a = '')
 {
     return ARC2::getSer('POSHRDF', $a);
 }
Example #4
0
 function getRSS10Serializer($a = '')
 {
     return ARC2::getSer('RSS10', $a);
 }
Example #5
0
 public function serialize($type = "RDFXML")
 {
     $serializer = ARC2::getSer($type, array("ns" => $this->g->ns));
     return $serializer->getSerializedTriples($this->toArcTriples());
 }
Example #6
0
 /**
  * Serialise an EasyRdf_Graph into RDF format of choice.
  *
  * @param string $graph An EasyRdf_Graph object.
  * @param string $format The name of the format to convert to.
  * @return string The RDF in the new desired format.
  */
 public function serialise($graph, $format)
 {
     if ($graph == null or !is_object($graph) or get_class($graph) != 'EasyRdf_Graph') {
         throw new InvalidArgumentException("\$graph should be an EasyRdf_Graph object and cannot be null");
     }
     if ($format == null or !is_string($format) or $format == '') {
         throw new InvalidArgumentException("\$format should be a string and cannot be null or empty");
     }
     $rdfphp = $this->to_rdfphp($graph);
     if ($format == 'php') {
         return $rdfphp;
     }
     if (array_key_exists($format, self::$_supportedTypes)) {
         $className = self::$_supportedTypes[$format];
     } else {
         throw new EasyRdf_Exception("Serialising documents to {$format} " . "is not supported by EasyRdf_Serialiser_Arc.");
     }
     $serialiser = ARC2::getSer($className);
     if ($serialiser) {
         return $serialiser->getSerializedIndex($rdfphp);
     } else {
         throw new EasyRdf_Exception("ARC2 failed to get a {$className} serialiser.");
     }
 }
Example #7
0
File: ARC2.php Project: semsol/arc2
 static function getJSONLDSerializer($a = '')
 {
     return ARC2::getSer('JSONLD', $a);
 }
Example #8
0
 /**
  * Returns the serialization of the entire RDF graph in memory using one of Arc2's serializers. By default the RDF/XML serializer is used, but others (try passing "Turtle" or "NTriples") can be used - see the Arc2 documentation.
  */
 public function serialize($type = "RDFXML")
 {
     $ns = $this->ns;
     unset($ns["dct"]);
     // use dcterms for preference. duplicates seem to cause
     // bugs in the serialiser
     $serializer = ARC2::getSer($type, array("ns" => $ns));
     return $serializer->getSerializedTriples($this->toArcTriples());
 }