当前位置: 首页>>代码示例>>PHP>>正文


PHP EasyRdf_Format::registerSerialiser方法代码示例

本文整理汇总了PHP中EasyRdf_Format::registerSerialiser方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Format::registerSerialiser方法的具体用法?PHP EasyRdf_Format::registerSerialiser怎么用?PHP EasyRdf_Format::registerSerialiser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EasyRdf_Format的用法示例。


在下文中一共展示了EasyRdf_Format::registerSerialiser方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createPersonAction

 /**
  * @Route("/create-person")
  */
 public function createPersonAction()
 {
     \EasyRdf_Format::registerSerialiser('ntriples', 'EasyRdf_Serialiser_Arc');
     \EasyRdf_Format::registerSerialiser('posh', 'EasyRdf_Serialiser_Arc');
     \EasyRdf_Format::registerSerialiser('rdfxml', 'EasyRdf_Serialiser_Arc');
     \EasyRdf_Format::registerSerialiser('turtle', 'EasyRdf_Serialiser_Arc');
     \EasyRdf_Namespace::set('foaf', 'http://xmlns.com/foaf/0.1/');
     $uri = 'http://www.example.com/emi#me';
     $name = 'Emi Berea';
     $emailStr = 'emi.berea@gmail.com';
     $homepageStr = 'http://bereae.me/';
     $graph = new \EasyRdf_Graph();
     # 1st Technique
     $me = $graph->resource($uri, 'foaf:Person');
     $me->set('foaf:name', $name);
     if ($emailStr) {
         $email = $graph->resource("mailto:" . $emailStr);
         $me->add('foaf:mbox', $email);
     }
     if ($homepageStr) {
         $homepage = $graph->resource($homepageStr);
         $me->add('foaf:homepage', $homepage);
     }
     # Finally output the graph
     $data = $graph->serialise('rdfxml');
     if (!is_scalar($data)) {
         $data = var_export($data, true);
     }
     var_dump($data);
     die;
 }
开发者ID:emiberea,项目名称:wade-phos-server,代码行数:34,代码来源:DefaultController.php

示例2: setUp

 public function setUp()
 {
     EasyRdf_Http::setDefaultHttpClient($this->_client = new EasyRdf_Http_MockClient());
     $this->_graphStore = new EasyRdf_GraphStore('http://localhost:8080/data/');
     // Ensure that the built-in n-triples parser is used
     EasyRdf_Format::registerSerialiser('ntriples', 'EasyRdf_Serialiser_Ntriples');
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:7,代码来源:GraphStoreTest.php

示例3: __construct

 public function __construct(EasyRdf_Graph $graph = null)
 {
     if ($graph === null) {
         $graph = new EasyRdf_Graph();
     }
     $this->graph = $graph;
     $this->uriGenerators = array();
     EasyRdf_Format::register('rdfxml', 'RDF/XML', 'http://www.w3.org/TR/rdf-syntax-grammar', 'application/rdf+xml');
     //EasyRdf_Format::registerParser( 'rdfxml', 'EasyRdf_Parser_RdfXml');
     EasyRdf_Format::registerSerialiser('rdfxml', 'EasyRdf_Serialiser_RdfXml');
 }
开发者ID:Tjoosten,项目名称:kvd,代码行数:11,代码来源:AbstractSerialiser.class.php

示例4: array

EasyRdf_Format::register('turtle', 'Turtle Terse RDF Triple Language', 'http://www.dajobe.org/2004/01/turtle', array('text/turtle' => 0.8, 'application/turtle' => 0.7, 'application/x-turtle' => 0.7), array('ttl'));
EasyRdf_Format::register('rdfxml', 'RDF/XML', 'http://www.w3.org/TR/rdf-syntax-grammar', array('application/rdf+xml' => 0.8), array('rdf', 'xrdf'));
EasyRdf_Format::register('dot', 'Graphviz', 'http://www.graphviz.org/doc/info/lang.html', array('text/vnd.graphviz' => 0.8), array('gv', 'dot'));
EasyRdf_Format::register('json-triples', 'RDF/JSON Triples');
EasyRdf_Format::register('n3', 'Notation3', 'http://www.w3.org/2000/10/swap/grammar/n3#', array('text/n3' => 0.5, 'text/rdf+n3' => 0.5), array('n3'));
EasyRdf_Format::register('rdfa', 'RDFa', 'http://www.w3.org/TR/rdfa-core/', array('text/html' => 0.4, 'application/xhtml+xml' => 0.4), array('html'));
EasyRdf_Format::register('sparql-xml', 'SPARQL XML Query Results', 'http://www.w3.org/TR/rdf-sparql-XMLres/', array('application/sparql-results+xml' => 1.0));
EasyRdf_Format::register('sparql-json', 'SPARQL JSON Query Results', 'http://www.w3.org/TR/rdf-sparql-json-res/', array('application/sparql-results+json' => 1.0));
EasyRdf_Format::register('png', 'Portable Network Graphics (PNG)', 'http://www.w3.org/TR/PNG/', array('image/png' => 0.3), array('png'));
EasyRdf_Format::register('gif', 'Graphics Interchange Format (GIF)', 'http://www.w3.org/Graphics/GIF/spec-gif89a.txt', array('image/gif' => 0.2), array('gif'));
EasyRdf_Format::register('svg', 'Scalable Vector Graphics (SVG)', 'http://www.w3.org/TR/SVG/', array('image/svg+xml' => 0.3), array('svg'));
/*
   Register default set of parsers and serialisers
*/
EasyRdf_Format::registerParser('json', 'EasyRdf_Parser_Json');
EasyRdf_Format::registerParser('ntriples', 'EasyRdf_Parser_Ntriples');
EasyRdf_Format::registerParser('php', 'EasyRdf_Parser_RdfPhp');
EasyRdf_Format::registerParser('rdfxml', 'EasyRdf_Parser_RdfXml');
EasyRdf_Format::registerParser('turtle', 'EasyRdf_Parser_Turtle');
EasyRdf_Format::registerParser('rdfa', 'EasyRdf_Parser_Rdfa');
EasyRdf_Format::registerSerialiser('json', 'EasyRdf_Serialiser_Json');
EasyRdf_Format::registerSerialiser('n3', 'EasyRdf_Serialiser_Turtle');
EasyRdf_Format::registerSerialiser('ntriples', 'EasyRdf_Serialiser_Ntriples');
EasyRdf_Format::registerSerialiser('php', 'EasyRdf_Serialiser_RdfPhp');
EasyRdf_Format::registerSerialiser('rdfxml', 'EasyRdf_Serialiser_RdfXml');
EasyRdf_Format::registerSerialiser('turtle', 'EasyRdf_Serialiser_Turtle');
EasyRdf_Format::registerSerialiser('dot', 'EasyRdf_Serialiser_GraphViz');
EasyRdf_Format::registerSerialiser('gif', 'EasyRdf_Serialiser_GraphViz');
EasyRdf_Format::registerSerialiser('png', 'EasyRdf_Serialiser_GraphViz');
EasyRdf_Format::registerSerialiser('svg', 'EasyRdf_Serialiser_GraphViz');
开发者ID:ASDAFF,项目名称:myprofile,代码行数:30,代码来源:Format.php

示例5: serialise

        /* not defined => ignore */
    }
    /**
     * Serialise an EasyRdf_Graph into N-Triples
     *
     * @param object EasyRdf_Graph $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 ($format != 'ntriples') {
            throw new EasyRdf_Exception("EasyRdf_Serialiser_Ntriples does not support: {$format}");
        }
        $nt = '';
        foreach ($graph->resources() as $resource) {
            foreach ($resource->propertyUris() as $property) {
                $objects = $resource->all($property);
                foreach ($objects as $object) {
                    $nt .= $this->ntriplesResource($resource) . " ";
                    $nt .= "<" . $this->escape($property) . "> ";
                    $nt .= $this->ntriplesObject($object) . " .\n";
                }
            }
        }
        return $nt;
    }
}
EasyRdf_Format::registerSerialiser('ntriples', 'EasyRdf_Serialiser_Ntriples');
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:30,代码来源:Ntriples.php

示例6: set_include_path

 */
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "EasyRdf.php";
require_once "html_tag_helpers.php";
if (isset($_REQUEST['enable_arc']) && $_REQUEST['enable_arc']) {
    require_once "EasyRdf/Serialiser/Arc.php";
    EasyRdf_Format::registerSerialiser('ntriples', 'EasyRdf_Serialiser_Arc');
    EasyRdf_Format::registerSerialiser('posh', 'EasyRdf_Serialiser_Arc');
    EasyRdf_Format::registerSerialiser('rdfxml', 'EasyRdf_Serialiser_Arc');
    EasyRdf_Format::registerSerialiser('turtle', 'EasyRdf_Serialiser_Arc');
}
if (isset($_REQUEST['enable_rapper']) && $_REQUEST['enable_rapper']) {
    require_once "EasyRdf/Serialiser/Rapper.php";
    EasyRdf_Format::registerSerialiser('dot', 'EasyRdf_Serialiser_Rapper');
    EasyRdf_Format::registerSerialiser('rdfxml', 'EasyRdf_Serialiser_Rapper');
    EasyRdf_Format::registerSerialiser('turtle', 'EasyRdf_Serialiser_Rapper');
}
$format_options = array();
foreach (EasyRdf_Format::getFormats() as $format) {
    if ($format->getSerialiserClass()) {
        $format_options[$format->getLabel()] = $format->getName();
    }
}
?>
<html>
<head><title>EasyRdf FOAF Maker Example</title></head>
<body>
<h1>EasyRdf FOAF Maker Example</h1>

<?php 
echo form_tag(null, array('method' => 'POST'));
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:foafmaker.php

示例7: serialise

    }
    /**
     * Serialise an EasyRdf_Graph into RDF format of choice.
     *
     * @param object EasyRdf_Graph $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("EasyRdf_Serialiser_Arc does not support: {$format}");
        }
        $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.");
        }
    }
}
# FIXME: to this automatically
EasyRdf_Format::register('posh', 'poshRDF');
EasyRdf_Format::registerSerialiser('ntriples', 'EasyRdf_Serialiser_Arc');
EasyRdf_Format::registerSerialiser('posh', 'EasyRdf_Serialiser_Arc');
EasyRdf_Format::registerSerialiser('rdfxml', 'EasyRdf_Serialiser_Arc');
EasyRdf_Format::registerSerialiser('turtle', 'EasyRdf_Serialiser_Arc');
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:Arc.php

示例8: serialise

 */
class EasyRdf_Serialiser_RdfPhp extends EasyRdf_Serialiser
{
    /**
     * 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.
     */
    /**
     * Method to serialise an EasyRdf_Graph to RDF/PHP
     *
     * http://n2.talis.com/wiki/RDF_PHP_Specification
     *
     * @param object EasyRdf_Graph $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 ($format != 'php') {
            throw new EasyRdf_Exception("EasyRdf_Serialiser_RdfPhp does not support: {$format}");
        }
        // Graph is already stored an RDF/PHP resource-centric array internally within the EasyRdf_Graph object
        return $graph->toArray();
    }
}
EasyRdf_Format::registerSerialiser('php', 'EasyRdf_Serialiser_RdfPhp');
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:30,代码来源:RdfPhp.php

示例9: testSerialiseByMime

 public function testSerialiseByMime()
 {
     EasyRdf_Format::registerSerialiser('mock', 'Mock_RdfSerialiser');
     EasyRdf_Format::register('mock', 'Mock', null, array('mock/mime' => 1.0));
     $graph = new EasyRdf_Graph();
     $this->assertEquals("<rdf></rdf>", $graph->serialise('mock/mime'));
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:7,代码来源:GraphTest.php

示例10: strcmp

            return strcmp($a['o'], $b['o']);
        } else {
            return 0;
        }
    }
    /**
     * Serialise an EasyRdf_Graph into an array of N-Triples objects
     *
     * @param object EasyRdf_Graph $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);
        $triples = array();
        foreach ($graph->toArray() as $resource => $properties) {
            foreach ($properties as $property => $values) {
                foreach ($values as $value) {
                    array_push($triples, array('s' => $this->ntriplesResource($resource), 'p' => "<" . $this->escapeString($property) . ">", 'o' => $this->ntriplesValue($value)));
                }
            }
        }
        // Sort the triples into a consistent order
        usort($triples, array($this, 'compareTriples'));
        return $triples;
    }
}
EasyRdf_Format::register('ntriples-array', 'PHP Array of Triples');
EasyRdf_Format::registerSerialiser('ntriples-array', 'EasyRdf_Serialiser_NtriplesArray');
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:30,代码来源:NtriplesArray.php

示例11: testRegisterSerialiserForUnknownFormat

 public function testRegisterSerialiserForUnknownFormat()
 {
     EasyRdf_Format::registerSerialiser('testRegisterSerialiser', 'MockSerialiserClass');
     $format = EasyRdf_Format::getFormat('testRegisterSerialiser');
     $this->assertNotNull($format);
     $this->assertEquals('MockSerialiserClass', $format->getSerialiserClass());
 }
开发者ID:nhukhanhdl,项目名称:easyrdf,代码行数:7,代码来源:FormatTest.php

示例12: serialise

 */
/**
 * Class to serialise an EasyRdf_Graph to RDF/JSON
 * with no external dependancies.
 *
 * @package    EasyRdf
 * @copyright  Copyright (c) 2009-2010 Nicholas J Humfrey
 * @license    http://www.opensource.org/licenses/bsd-license.php
 */
class EasyRdf_Serialiser_Json extends EasyRdf_Serialiser_RdfPhp
{
    /**
     * Method to serialise an EasyRdf_Graph to RDF/JSON
     *
     * http://n2.talis.com/wiki/RDF_JSON_Specification
     *
     * @param object EasyRdf_Graph $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 ($format != 'json') {
            throw new EasyRdf_Exception("EasyRdf_Serialiser_Json does not support: {$format}");
        }
        return json_encode(parent::serialise($graph, 'php'));
    }
}
EasyRdf_Format::registerSerialiser('json', 'EasyRdf_Serialiser_Json');
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:Json.php

示例13: serialise

     * @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 ($format != 'rdfxml') {
            throw new EasyRdf_Exception("EasyRdf_Serialiser_RdfXml does not support: {$format}");
        }
        // store of namespaces to be appended to the rdf:RDF tag
        $this->_prefixes = array('rdf' => true);
        // store of the resource URIs we have serialised
        $this->_outputtedResources = array();
        $xml = '';
        foreach ($graph->resources() as $resource) {
            $xml .= $this->rdfxmlResource($resource, true, 1);
        }
        // iterate through namepsaces array prefix and output a string.
        $namespaceStr = '';
        foreach ($this->_prefixes as $prefix => $count) {
            $url = EasyRdf_Namespace::get($prefix);
            if (strlen($namespaceStr)) {
                $namespaceStr .= "\n        ";
            }
            $namespaceStr .= ' xmlns:' . $prefix . '="' . htmlspecialchars($url) . '"';
        }
        return "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" . "<rdf:RDF" . $namespaceStr . ">\n" . $xml . "\n</rdf:RDF>\n";
    }
}
EasyRdf_Format::registerSerialiser('rdfxml', 'EasyRdf_Serialiser_RdfXml');
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:RdfXml.php


注:本文中的EasyRdf_Format::registerSerialiser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。