From 7fed7382349b85f48b9d4fcc504bee1776ab0480 Mon Sep 17 00:00:00 2001 From: Konrad Abicht Date: Wed, 3 Apr 2024 11:01:38 +0200 Subject: [PATCH] extend Util.php to accept rdfxml in getParser and getSerializer This patch makes Util::getParser and Util::getSerializer compatible with EasyRdf's Format::guessFormat return values --- src/quickRdfIo/Util.php | 2 ++ tests/UtilTest.php | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/quickRdfIo/Util.php b/src/quickRdfIo/Util.php index 1530c0d..5c347f1 100644 --- a/src/quickRdfIo/Util.php +++ b/src/quickRdfIo/Util.php @@ -82,6 +82,7 @@ static public function getSerializer(string $formatOrFilename): iSerializer { 'application/n-quads' => new NQuadsSerializer(), 'xml', 'rdf', + 'rdfxml', // EasyRdf is using it in Format::guessFormat 'application/rdf+xml', 'text/rdf', 'application/xml', @@ -135,6 +136,7 @@ static public function getParser(string $formatOrFilename, 'application/n-quads' => new NQuadsParser($dataFactory, false, NQuadsParser::MODE_QUADS_STAR), 'xml', 'rdf', + 'rdfxml', // EasyRdf is using it in Format::guessFormat 'application/rdf+xml', 'text/rdf', 'application/xml', diff --git a/tests/UtilTest.php b/tests/UtilTest.php index b6dbc05..9465dc8 100644 --- a/tests/UtilTest.php +++ b/tests/UtilTest.php @@ -44,6 +44,16 @@ static public function setUpBeforeClass(): void { self::$dfSimple = new \simpleRdf\DataFactory(); } + public function testGetParser(): void { + $parser = Util::getParser('rdfxml', self::$dfQuick); + $this->assertTrue($parser instanceof RdfXmlParser); + } + + public function testGetSerializer(): void { + $serializer = Util::getSerializer('rdfxml'); + $this->assertTrue($serializer instanceof RdfXmlSerializer); + } + public function testParse(): void { $url = 'https://www.w3.org/2000/10/rdf-tests/RDF-Model-Syntax_1.0/ms_7.2_1.rdf'; $client = new \GuzzleHttp\Client();