rdflib icon indicating copy to clipboard operation
rdflib copied to clipboard

querying multiple ttl files

Open luisenriqueramos1977 opened this issue 1 year ago • 5 comments

I have two simple ttl files with following data:

example1.ttl:

ns1:place1 a a owl:NamedIndividual;
                 ns2:hasAddress address_1 .

example2.ttl:

ns2:address_1 a a owl:NamedIndividual;
                 ns2:hasproperty1 property1 .
                 ns2:hasproperty2 property2 .

I uploaded the files with:

g.parse(example1.ttl)
g.parse(example2.ttl)

when I use sparql to get the address of place:

SELECT ?address
WHERE {  
        ns1:place1  ns2:hasAddress ?address .
        }

I get the expected address object

when I ask for all properties of address object:
SELECT ?property ?value 
WHERE {  
        ns2:address_1 ?property ?value .
        }
I also get them, but when I ask for the properties of the address of the place:

SELECT  ?property ?value
WHERE {  
        ns1:place1  ns2:hasAddress ?address .
        ?address ?property ?value .
        }

I get a blank result, I wonder what should I be doing wrong?,

Because I was waiting to get all properties of the address.

Best regards

Luis

luisenriqueramos1977 avatar Sep 04 '23 13:09 luisenriqueramos1977

These are not real examples (prefixes are missing etc.). You should create a Gist with all the files.

namedgraph avatar Sep 11 '23 13:09 namedgraph

Thanks for oyur answer Martynas Jusevičius, at the end I solved the issue removing the name spaces and working directly with full uri.

luisenriqueramos1977 avatar Sep 18 '23 08:09 luisenriqueramos1977

In your examples:

example1.ttl:
ns1:place1 a a owl:NamedIndividual;
ns2:hasAddress address_1 .

example2.ttl:
ns2:address_1 a a owl:NamedIndividual;
ns2:hasproperty1 property1 .
ns2:hasproperty2 property2 .

The first address_1 in example1.ttl has no namespace prefix, but the second one ns2:address_1 in example2.ttl has.

RinkeHoekstra avatar Sep 21 '23 07:09 RinkeHoekstra

@luisenriqueramos1977 could you close the issue?

RinkeHoekstra avatar Sep 21 '23 07:09 RinkeHoekstra

@luisenriqueramos1977 what version of RDFLib were you using?

aucampia avatar Sep 24 '23 17:09 aucampia