Rdf TypeMapper类对象属性为空

Rdf TypeMapper类对象属性为空,rdf,rdfs,easyrdf,Rdf,Rdfs,Easyrdf,我不熟悉rdf和easyrdf框架。我们目前正在创建一个小型poc,看看它是否适合我们的需要 我们希望将给定的RDF文件或数据(例如,以RDF/xml格式)转换为类对象 因此,我已经通过TypeMapper注册了该类 TypeMapper::set('foaf:Product', RdfProduct::class); TypeMapper::set('foaf:Price', RdfProductPrice::class); 我的班级: class RdfProduct extends Re

我不熟悉rdf和easyrdf框架。我们目前正在创建一个小型poc,看看它是否适合我们的需要

我们希望将给定的RDF文件或数据(例如,以RDF/xml格式)转换为类对象

因此,我已经通过TypeMapper注册了该类

TypeMapper::set('foaf:Product', RdfProduct::class);
TypeMapper::set('foaf:Price', RdfProductPrice::class);
我的班级:

class RdfProduct extends Resource
{
    /** @var string */
    public $productID;
    /** @var string */
    public $name;
    /** @var string */
    public $description;

    //Do they have to be public oder private? with getters/setters?!
}
我的数据文件:

<?xml version="1.0" encoding="utf-8" ?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:foaf="http://xmlns.com/foaf/0.1/">

    <foaf:Product rdf:about="http://test.com/product">
        <foaf:productID xml:lang="de_DE">e16d61860c644d4088de12b67e22f3b2</foaf:productID>
        <foaf:name xml:lang="de_DE">Demo Produkt</foaf:name>
        <foaf:name xml:lang="en_GB">Demo Product</foaf:name>
        <foaf:description xml:lang="de_DE">Test Beschreibung Lorem Ipsum</foaf:description>
        <foaf:description xml:lang="en_GB">Test description Lorem Ipsum</foaf:description>
        <foaf:brand xml:lang="de_DE">Test</foaf:brand>
        <foaf:height xml:lang="de_DE">120</foaf:height>
        <foaf:depth xml:lang="de_DE">210</foaf:depth>
        <foaf:weight xml:lang="de_DE">2.5</foaf:weight>
        <foaf:width xml:lang="de_DE">100</foaf:width>
        <foaf:manufacturer xml:lang="de_DE">Test GmbH</foaf:manufacturer>
        <foaf:sku xml:lang="de_DE">DemoTest1</foaf:sku>
        <foaf:hasVariant xml:lang="de_DE"></foaf:hasVariant>
        <foaf:price>
            <foaf:Price rdf:about="http://test.com/product/price">
                <foaf:net rdf:datatype="http://www.w3.org/2001/XMLSchema#double">17.31</foaf:net>
                <foaf:gross rdf:datatype="http://www.w3.org/2001/XMLSchema#double">20.59</foaf:gross>
            </foaf:Price>
        </foaf:price>

        <foaf:category>
            <foaf:Category rdf:about="http://test.com/product/category">
                <foaf:name>Main</foaf:name>
                <foaf:name>Submain</foaf:name>
            </foaf:Category>
        </foaf:category>

        <foaf:media>
            <foaf:Media rdf:about="http://test.com/product/media">
                <foaf:MediaItem>
                    <foaf:MediaItem rdf:about="http://test.com/product/media-item">
                        <foaf:url>https://test.com/test.png</foaf:url>
                        <foaf:url>https://test.com/test.jpg
                        </foaf:url>
                    </foaf:MediaItem>
                </foaf:MediaItem>

            </foaf:Media>
        </foaf:media>

    </foaf:Product>

</rdf:RDF>
但是类的属性为空

有什么想法吗?我还可以拥有一个RdfProduct对象实例并将其转换回rdf格式吗

TypeMapper::set('foaf:Product', RdfProduct::class);
TypeMapper::set('foaf:Price', RdfProductPrice::class);

$rdfXml = file_get_contents(__DIR__ . '/product-demo.xml');

$graph = new Graph(
  'http://test.com/product',
  $rdfXml,
  'rdfxml'
);
        
$rdfProduct = current($graph->resources());
dd($rdfProduct);