From: Michele P. <mic...@gm...> - 2008-04-01 15:10:19
|
Hi all, I'm getting this error with the MemModel - when adding properties to a resource which has been previously created, instead of getting the rdf:About ...ResourceID construct, the output is rdf:ID='ResourceID'. Not sure whether it's an error or not, but the w3cRDF-validator apparently says so: Error: {W105} Redefinition of ID: node_node1[Line = 20, Column = 38] Error: {W105} Previous definition of 'node_node1'.[Line = 16, Column = 32] Here's the complete RDF code I've generated: ;;;;;;;;;;;;;;;;;;;;;;;; <?xml version="1.0" encoding="UTF-8" ?> <!-- Generated by RdfSerializer.php from RDF RAP. # http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/index.html !--> <rdf:RDF xml:base="http://cohereweb.net/ontology/cohere.owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:ns1="http://cohereweb.net/ontology/cohere.owl#"> <ns1:node rdf:ID="node1"/> <ns1:cohere_user rdf:ID="michele"/> <rdf:Description rdf:ID="node1"> <ns1:has_creator rdf:resource="#michele"/> </rdf:Description> </rdf:RDF> ;;;;;;;;;;;;;;;;;;;;;;;;;; And here's the PHP code: ................ //test function function get_result2 ($nodeID, $nodeName, $nodeDescription, $authorID) { //load all it's necessary loadRapLibraries("../import/rdfapi-php/api/"); //create a new model $model = getCohereModel(); //create resources using my own vocabulary $newnode = new Resource(COHERE_NS . $nodeID); $newauthor = new Resource(COHERE_NS . $authorID); // create statements $statement1 = new Statement ($newnode, RDF_RES::TYPE(), COHERE_RES::NODE()); $statement2 = new Statement ($newauthor, RDF_RES::TYPE(), COHERE_RES::COHERE_USER()); $statement3 = new Statement ($newnode, COHERE_RES::HAS_CREATOR(), $newauthor); //add the statements $model->addWithoutDuplicates($statement1); $model->addWithoutDuplicates($statement2); $model->addWithoutDuplicates($statement3); $ret = $model->writeAsHtml(); return $ret; } echo get_result2("node1", "myNode", "myDesc", "michele"); ................ I can't figure out where the mistake is - can anybody help please? Thanks a lot, mikele |
From: Tom H. <tom...@gm...> - 2008-04-02 09:09:35
|
Hey Mik, With the "node" property in your own namespace it's quite hard to work out what you're actually trying to say. Any chance you can show us an example of the triples you'd like to generate, perhaps as n-triples, and then it'll be easier to debug the PHP. It's probably also worth using CamelCase for class names in your ontology, as this is a widely used convention and makes the RDF more readable. Cheers, Tom. On 01/04/2008, Michele Pasin <mic...@gm...> wrote: > Hi all, > > I'm getting this error with the MemModel - when adding properties to a > resource which has been previously created, instead of getting the rdf:About > ...ResourceID construct, the output is rdf:ID='ResourceID'. Not sure > whether it's an error or not, but the w3cRDF-validator apparently says so: > > > > Error: {W105} Redefinition of ID: node_node1[Line = 20, Column = 38] > Error: {W105} Previous definition of 'node_node1'.[Line = 16, Column = 32] > > > Here's the complete RDF code I've generated: > > ;;;;;;;;;;;;;;;;;;;;;;;; > <?xml version="1.0" encoding="UTF-8" ?> > <!-- Generated by RdfSerializer.php from RDF RAP. > # > http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/index.html > !--> > > <rdf:RDF > xml:base="http://cohereweb.net/ontology/cohere.owl#" > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > xmlns:owl="http://www.w3.org/2002/07/owl#" > xmlns:dc="http://purl.org/dc/elements/1.1/" > xmlns:dcterms="http://purl.org/dc/terms/" > xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#" > xmlns:ns1="http://cohereweb.net/ontology/cohere.owl#"> > > <ns1:node rdf:ID="node1"/> > > <ns1:cohere_user rdf:ID="michele"/> > > <rdf:Description rdf:ID="node1"> > <ns1:has_creator rdf:resource="#michele"/> > </rdf:Description> > > </rdf:RDF> > ;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > And here's the PHP code: > > > ................ > > > > > > > > > > > //test function > > function get_result2 ($nodeID, $nodeName, $nodeDescription, $authorID) { > > //load all it's necessary > > loadRapLibraries("../import/rdfapi-php/api/"); > > > > > //create a new model > > $model = getCohereModel(); > > > > //create resources using my own vocabulary > > $newnode = new Resource(COHERE_NS . $nodeID); > > $newauthor = new Resource(COHERE_NS . $authorID); > > > > // create statements > > $statement1 = new Statement ($newnode, RDF_RES::TYPE(), > COHERE_RES::NODE()); > > > > > $statement2 = new Statement ($newauthor, RDF_RES::TYPE(), > COHERE_RES::COHERE_USER()); > > > > $statement3 = new Statement ($newnode, COHERE_RES::HAS_CREATOR(), > $newauthor); > > > > //add the statements > > $model->addWithoutDuplicates($statement1); > > > > > $model->addWithoutDuplicates($statement2); > > > > $model->addWithoutDuplicates($statement3); > > > > $ret = $model->writeAsHtml(); > > return $ret; > > } > > > > > > > echo get_result2("node1", "myNode", "myDesc", "michele"); > > > > > > > > > ................ > > > > > > > > I can't figure out where the mistake is - can anybody help please? > Thanks a lot, > mikele > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Rdfapi-php-interest mailing list > Rdf...@li... > https://lists.sourceforge.net/lists/listinfo/rdfapi-php-interest > > |
From: Michele P. <mic...@gm...> - 2008-04-02 13:01:10
|
Hey Tom, sorry about the 'node' class, i'm so used to it I don't find it confusing anymore. So here's a simplified example in PHP, which you can easily run by yourself. Basically all I'm trying to write is 3 triples as follows: ($ID ---> rdf:TYPE -----> "http://cohereweb.net/ontology/cohere.owl#node") ($authorID ---> rdf:TYPE -----> " http://cohereweb.net/ontology/cohere.owl#cohere_user") ($ID ---> ""http://cohereweb.net/ontology/cohere.owl#has_creator" -----> $name) And here's the code: ........................................ get_result("myID", "myName", "myAuthorID"); function get_result ($ID, $Name, $authorID) { loadRapLibraries("../import/rdfapi-php/api/"); define('COHERE_NS', 'http://cohereweb.net/ontology/cohere.owl#'); $Model = ModelFactory::getDefaultModel(RDFS_VOCABULARY); $Model->setBaseURI(COHERE_NS); $newclaimID = new Resource(COHERE_NS . $ID); $newauthor = new Resource(COHERE_NS . $authorID); $statement1 = new Statement ($newclaimID, RDF_RES::TYPE(), new Resource ("http://cohereweb.net/ontology/cohere.owl#node")); $statement2 = new Statement ($newauthor, RDF_RES::TYPE(), new Resource ("http://cohereweb.net/ontology/cohere.owl#cohere_user")); $statement3 = new Statement ($newclaimID, new Resource (" http://cohereweb.net/ontology/cohere.owl#has_creator"), $newauthor); $Model->addWithoutDuplicates($statement1); $Model->addWithoutDuplicates($statement2); $Model->addWithoutDuplicates($statement3); $ret = $Model->writeAsHtml(); return $ret; } ........................................... the rdf I get is (without namespaces): <ns1:node rdf:ID="myID"/> <ns1:cohere_user rdf:ID="myAuthorID"/> <rdf:Description rdf:ID="myID"> <ns1:has_creator rdf:resource="#myAuthorID"/> </rdf:Description> which is wrong because the [rdf:ID="myID"/>] is redefined in the first statement and the third one. I guess it should be something like [rdf:about='myID"/>] in the third one.. but i'm no expert here!! Anyways, a simple workaround is that if you just change the order of the statements added (putting the statement 2 first) the whole thing works. That is, from: $Model->addWithoutDuplicates($statement1); $Model->addWithoutDuplicates($statement2); $Model->addWithoutDuplicates($statement3); to $Model->addWithoutDuplicates($statement2); $Model->addWithoutDuplicates($statement1); $Model->addWithoutDuplicates($statement3); Then the resulting RDF is valid: <ns1:cohere_user rdf:ID="myAuthorID"/> <ns1:node rdf:ID="myID"> <ns1:has_creator rdf:resource="#myAuthorID"/> </ns1:node> Hope it's clearer now.... any idea where I'm getting it wrong? Tx a lot mik On Wed, Apr 2, 2008 at 10:09 AM, Tom Heath <tom...@gm...> wrote: > Hey Mik, > > With the "node" property in your own namespace it's quite hard to work > out what you're actually trying to say. Any chance you can show us an > example of the triples you'd like to generate, perhaps as n-triples, > and then it'll be easier to debug the PHP. > > It's probably also worth using CamelCase for class names in your > ontology, as this is a widely used convention and makes the RDF more > readable. > > Cheers, > > Tom. > > On 01/04/2008, Michele Pasin <mic...@gm...> wrote: > > Hi all, > > > > I'm getting this error with the MemModel - when adding properties to a > > resource which has been previously created, instead of getting the > rdf:About > > ...ResourceID construct, the output is rdf:ID='ResourceID'. Not sure > > whether it's an error or not, but the w3cRDF-validator apparently says > so: > > > > > > > > Error: {W105} Redefinition of ID: node_node1[Line = 20, Column = 38] > > Error: {W105} Previous definition of 'node_node1'.[Line = 16, Column = > 32] > > > > > > Here's the complete RDF code I've generated: > > > > ;;;;;;;;;;;;;;;;;;;;;;;; > > <?xml version="1.0" encoding="UTF-8" ?> > > <!-- Generated by RdfSerializer.php from RDF RAP. > > # > > http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/index.html > > !--> > > > > <rdf:RDF > > xml:base="http://cohereweb.net/ontology/cohere.owl#" > > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > > xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > > xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > > xmlns:owl="http://www.w3.org/2002/07/owl#" > > xmlns:dc="http://purl.org/dc/elements/1.1/" > > xmlns:dcterms="http://purl.org/dc/terms/" > > xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#" > > xmlns:ns1="http://cohereweb.net/ontology/cohere.owl#"> > > > > <ns1:node rdf:ID="node1"/> > > > > <ns1:cohere_user rdf:ID="michele"/> > > > > <rdf:Description rdf:ID="node1"> > > <ns1:has_creator rdf:resource="#michele"/> > > </rdf:Description> > > > > </rdf:RDF> > > ;;;;;;;;;;;;;;;;;;;;;;;;;; > > > > > > > > And here's the PHP code: > > > > > > ................ > > > > > > > > > > > > > > > > > > > > > > //test function > > > > function get_result2 ($nodeID, $nodeName, $nodeDescription, $authorID) { > > > > //load all it's necessary > > > > loadRapLibraries("../import/rdfapi-php/api/"); > > > > > > > > > > //create a new model > > > > $model = getCohereModel(); > > > > > > > > //create resources using my own vocabulary > > > > $newnode = new Resource(COHERE_NS . $nodeID); > > > > $newauthor = new Resource(COHERE_NS . $authorID); > > > > > > > > // create statements > > > > $statement1 = new Statement ($newnode, RDF_RES::TYPE(), > > COHERE_RES::NODE()); > > > > > > > > > > $statement2 = new Statement ($newauthor, RDF_RES::TYPE(), > > COHERE_RES::COHERE_USER()); > > > > > > > > $statement3 = new Statement ($newnode, COHERE_RES::HAS_CREATOR(), > > $newauthor); > > > > > > > > //add the statements > > > > $model->addWithoutDuplicates($statement1); > > > > > > > > > > $model->addWithoutDuplicates($statement2); > > > > > > > > $model->addWithoutDuplicates($statement3); > > > > > > > > $ret = $model->writeAsHtml(); > > > > return $ret; > > > > } > > > > > > > > > > > > > > echo get_result2("node1", "myNode", "myDesc", "michele"); > > > > > > > > > > > > > > > > > > ................ > > > > > > > > > > > > > > > > I can't figure out where the mistake is - can anybody help please? > > Thanks a lot, > > mikele > > > > > > > ------------------------------------------------------------------------- > > Check out the new SourceForge.net Marketplace. > > It's the best place to buy or sell services for > > just about anything Open Source. > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > _______________________________________________ > > Rdfapi-php-interest mailing list > > Rdf...@li... > > https://lists.sourceforge.net/lists/listinfo/rdfapi-php-interest > > > > > |
From: Michele P. <mic...@gm...> - 2008-04-23 14:58:38
|
Hey everybody, I solved the issue so I thought someone else could have benefited from this. The problem was that every time I was referencing to a resource, this was created using the RDF:ID construct. Which is ok, as far as the resource is not mentioned anymore using the same RDF:iD construct. Which for some reasons was not happening .......The W3c RDF specs say: "So for example if rdf:ID="name", that would be equivalent to rdf:about="#name". rdf:ID provides an additional check since the same *name*can only appear once in the scope of an xml:base value (or document, if none is given) [...]" My knowledge of RAP is limited, but for some reasons when the namespace was set, it kept creating RDF:ID references irrespectively of whether it wasnt the first time the resource is mentioned. And subsequently the RDF validator was throwing an error......After a few trials I realized that the source of the error was the BASEURI declaration at the beginning: $Model->setBaseURI(COHERE_NS); once I got rid of that and started using full uris when creating new Resources, the output was using RDF:ABOUT and thus it validates too. rdf:About = rdf:about="http://cohere.......website_13710..................." instead of the previous rdf:ID="website_13710........" does it make sense to anybody? mik On Wed, Apr 2, 2008 at 2:01 PM, Michele Pasin <mic...@gm...> wrote: > Hey Tom, > > sorry about the 'node' class, i'm so used to it I don't find it confusing > anymore. So here's a simplified example in PHP, which you can easily run by > yourself. Basically all I'm trying to write is 3 triples as follows: > > ($ID ---> rdf:TYPE -----> "http://cohereweb.net/ontology/cohere.owl#node") > ($authorID ---> rdf:TYPE -----> " > http://cohereweb.net/ontology/cohere.owl#cohere_user") > ($ID ---> ""http://cohereweb.net/ontology/cohere.owl#has_creator" -----> > $name) > > > And here's the code: > ........................................ > .................... > |