|
From: <pl...@do...> - 2007-07-09 15:45:43
|
Dear all,
I've been working with RDF datasets and persistent named graphs in RAP =20
today, and have encountered some unexpected behaviour. I'm not sure if =20
this is a result of my misunderstanding the documentation, or of a bug =20
somewhere in RAP; I hope someone here will be able to help!
Suppose I create two datasets, and create a named graph in each with =20
the same URI. If I add a statement to the first of these, it is added =20
to only the first model (as I'd expect). If, however, at a later time =20
I get these datasets and graphs again, and again add a statement to =20
the first model, I find it has propagated to /both/ of these models.
I have to confess to more than just mild confusion at this point :) =20
I've enclsoed as close as I can get to a complete-minimal-runnable =20
test case. The code below produces the given output on two successive =20
runs:
__________________________________________________________________
Code:
<?php
define("RDFAPI_INCLUDE_DIR", "api/");
require_once(RDFAPI_INCLUDE_DIR . "RdfAPI.php");
require_once(RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF);
require_once(RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_N3);
define("BASE", "http://example.com/");
$name =3D BASE . 'models/named/content';
$dbconn =3D ModelFactory::getDbStore( 'MySQL', 'localhost', 'example', =20
'example', 'example' );
$ddb1 =3D $dbconn->getDatasetDb( BASE . 'models/knows' );
if ( $ddb1 =3D=3D=3D false )
$ddb1 =3D $dbconn->getNewDatasetDb( BASE . 'models/knows' );
$ddb2 =3D $dbconn->getDatasetDb( BASE . 'models/names' );
if ( $ddb2 =3D=3D=3D false )
$ddb2 =3D $dbconn->getNewDatasetDb( BASE . 'models/names' );
if ( $ddb1->containsNamedGraph( $name ) )
$c1 =3D $ddb1->getNamedGraph( $name );
else
$c1 =3D $ddb1->createGraph( $name );
if ( $ddb2->containsNamedGraph( $name ) )
$c2 =3D $ddb2->getNamedGraph( $name );
else
$c2 =3D $ddb2->createGraph( $name );
$c1->add( new Statement( new Resource( BASE . 'someSubject' ), new =20
Resource( BASE . 'somePredicate' ), new Literal( 'Some Object' ) ) );
$c1->writeAsHtml();
echo "<br /><br />\n";
$c2->writeAsHtml();
?>
__________________________________________________________________
First Execution:
<?xml version=3D"1.0" encoding=3D"UTF-8" ?>
<!-- Generated by RdfSerializer.php from RDF RAP.
# http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/index.html !-->
<rdf:RDF
xmlns:rdf=3D"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs=3D"http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema#"
xmlns:owl=3D"http://www.w3.org/2002/07/owl#"
xmlns:dc=3D"http://purl.org/dc/elements/1.1/"
xmlns:dcterms=3D"http://purl.org/dc/terms/"
xmlns:vcard=3D"http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:ns1=3D"http://example.com/">
<rdf:Description rdf:about=3D"http://example.com/someSubject">
<ns1:somePredicate>Some Object</ns1:somePredicate>
</rdf:Description>
</rdf:RDF>
<rdf:RDF xmlns:rdf=3D'http://www.w3.org/1999/02/22-rdf-syntax-ns#' />
__________________________________________________________________
Second Execution:
<?xml version=3D"1.0" encoding=3D"UTF-8" ?>
<!-- Generated by RdfSerializer.php from RDF RAP.
# http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/index.html !-->
<rdf:RDF
xmlns:rdf=3D"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs=3D"http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema#"
xmlns:owl=3D"http://www.w3.org/2002/07/owl#"
xmlns:dc=3D"http://purl.org/dc/elements/1.1/"
xmlns:dcterms=3D"http://purl.org/dc/terms/"
xmlns:vcard=3D"http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:ns1=3D"http://example.com/">
<rdf:Description rdf:about=3D"http://example.com/someSubject">
<ns1:somePredicate>Some Object</ns1:somePredicate>
</rdf:Description>
</rdf:RDF>
<?xml version=3D"1.0" encoding=3D"UTF-8" ?>
<!-- Generated by RdfSerializer.php from RDF RAP.
# http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/index.html !-->
<rdf:RDF
xmlns:rdf=3D"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs=3D"http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema#"
xmlns:owl=3D"http://www.w3.org/2002/07/owl#"
xmlns:dc=3D"http://purl.org/dc/elements/1.1/"
xmlns:dcterms=3D"http://purl.org/dc/terms/"
xmlns:vcard=3D"http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:ns1=3D"http://example.com/">
<rdf:Description rdf:about=3D"http://example.com/someSubject">
<ns1:somePredicate>Some Object</ns1:somePredicate>
</rdf:Description>
</rdf:RDF>
__________________________________________________________________
As an aside; if I create these statements through the addQuad() =20
interface, it adds them only to the first model, as I'd have expected.
I hope that I've enclosed enough information for someone to be able to =20
reproduce this behaviour (and that I've not just wasted everyone's =20
time through my own stupidity ;)
Thanks in advance for your time, and any suggestions you may have!
Cheers,
Peter
|