X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Feasyrdf%2Feasyrdf%2Flib%2FEasyRdf%2FParser%2FArc.php;fp=vendor%2Feasyrdf%2Feasyrdf%2Flib%2FEasyRdf%2FParser%2FArc.php;h=b4e5e1ef5bf5d6310d5595c078a310643b657f13;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Arc.php b/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Arc.php new file mode 100644 index 000000000..b4e5e1ef5 --- /dev/null +++ b/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Arc.php @@ -0,0 +1,96 @@ + 'RDFXML', + 'turtle' => 'Turtle', + 'ntriples' => 'Turtle', + 'rdfa' => 'SemHTML', + ); + + /** + * Constructor + * + * @return object EasyRdf_Parser_Arc + */ + public function __construct() + { + require_once 'arc/ARC2.php'; + } + + /** + * Parse an RDF document into an EasyRdf_Graph + * + * @param object EasyRdf_Graph $graph the graph to load the data into + * @param string $data the RDF document data + * @param string $format the format of the input data + * @param string $baseUri the base URI of the data being parsed + * @return integer The number of triples added to the graph + */ + public function parse($graph, $data, $format, $baseUri) + { + parent::checkParseParams($graph, $data, $format, $baseUri); + + if (array_key_exists($format, self::$supportedTypes)) { + $className = self::$supportedTypes[$format]; + } else { + throw new EasyRdf_Exception( + "EasyRdf_Parser_Arc does not support: $format" + ); + } + + $parser = ARC2::getParser($className); + if ($parser) { + $parser->parse($baseUri, $data); + $rdfphp = $parser->getSimpleIndex(false); + return parent::parse($graph, $rdfphp, 'php', $baseUri); + } else { + throw new EasyRdf_Exception( + "ARC2 failed to get a $className parser." + ); + } + } +}