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

Reply via email to