Hello Roland! There have been some fixes for the SPARQL-support since release 2.3.3. If you check out the latest trunk (easiest to do with "easy_install -U rdflib==dev" if you have setuptools installed) you should get the expected result. I ran your example and got the last value as:
[(rdflib.URIRef('#rohe0001'), None, rdflib.Literal('[EMAIL PROTECTED]', language=None, datatype=None), None, None), (rdflib.URIRef('#evma0001'), None, rdflib.Literal('[EMAIL PROTECTED]', language=None, datatype=None), None, None)] which looks right, as I see it. RDFLib 2.4.0 is in the pipe, and will be released real soon now. (Am I right on this Daniel?) Best regards, Niklas Lindström On 3/27/07, Roland Hedberg <[EMAIL PROTECTED]> wrote: > Hi! > > I'm not sure where the problem it but the results I get are pretty weird. > > I'm using rdflib version 2.3.3 > > I have a store (ConjunctiveGraph) that contains the following graphs: > > <rdf:RDF xmlns="http://www.openmetadir.org/om2/prim.owl#" > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> > > <Person rdf:about="#evma0001"> > <contactInfo rdf:nodeID="b2"/> > <givenName>Eva</givenName> > <surName>Magnusson</surName> > </Person> > > <Person rdf:about="#rohe0001"> > <contactInfo rdf:nodeID="b1"/> > <givenName>Roland</givenName> > <surName>Hedberg</surName> > </Person> > > <Email rdf:nodeID="b1"> > <address>[EMAIL PROTECTED]</address> > </Email> > > <Email rdf:nodeID="b2"> > <address>[EMAIL PROTECTED]</address> > </Email> > </rdf:RDF> > > It's simply two persons, and some contact information for them. > > Now, if I send the following SPARQL query > > PREFIX a: <#> > PREFIX c: <http://www.openmetadir.org/om2/prim.owl#> > PREFIX b: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> > SELECT ?b ?c ?d ?e > WHERE { > a:rohe0001 b:type c:Person . > a:rohe0001 c:contactInfo ?a . > ?a b:type c:Email . > OPTIONAL { ?a c:validTo ?b } . > OPTIONAL { ?a c:address ?c } . > OPTIONAL { ?a c:validFrom ?d } . > OPTIONAL { ?a c:contactType ?e } . > } > > I would expect to get: > > [(None,"[EMAIL PROTECTED]",None,None)] > > and I do. > But if I reissue the query but now modify it slightly: > > PREFIX c: <http://www.openmetadir.org/om2/prim.owl#> > PREFIX b: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> > SELECT ?id ?b ?c ?d ?e > WHERE { > ?id b:type c:Person . > ?id c:contactInfo ?a . > ?a b:type c:Email . > OPTIONAL { ?a c:validTo ?b } . > OPTIONAL { ?a c:address ?c } . > OPTIONAL { ?a c:validFrom ?d } . > OPTIONAL { ?a c:contactType ?e } . > } > > I expected to get back: > > [("#rohe0001",None,"[EMAIL PROTECTED]",None,None), > ("#evma0001",None,"[EMAIL PROTECTED]",None,None)] > > but I don't, I get > > [("#rohe0001",None,"[EMAIL PROTECTED]",None,None), > ("#evma0001",None,"[EMAIL PROTECTED]",None,None), > ("#rohe0001",None,"[EMAIL PROTECTED]",None,None), > ("#evma0001",None,"[EMAIL PROTECTED]",None,None)] > > which was to me totally unexpected. > > Anyone who can tell me why I got this result ? > > -- Roland > > > > _______________________________________________ > Dev mailing list > Dev@rdflib.net > http://rdflib.net/mailman/listinfo/dev > _______________________________________________ Dev mailing list Dev@rdflib.net http://rdflib.net/mailman/listinfo/dev