antoniogarrote / rdfstore-js

JS RDF store with SPARQL support
MIT License
563 stars 109 forks source link

Sparql engine PREFIX issue with named GRAPH structures? #100

Open Public-Health-Bioinformatics opened 9 years ago

Public-Health-Bioinformatics commented 9 years ago

Hi Antonio,

First to say this is great stuff - very useful. I did run into a problem with the PREFIX parameter though:

var sparql = "PREFIX ifm: http://www.semanticweb.org/damion/ontologies/IFM_ontology# \ PREFIX owl: http://www.w3.org/2002/07/owl \ SELECT ?datumId ?restriction ?whatever \ FROM NAMED { GRAPH { \ ?datumId rdfs:subClassOf ?restriction.\ ?restriction rdf:type http://www.w3.org/2002/07/owl#Restriction.\ }} LIMIT 100"

Against my ontology, the above query succeeds. But if the http://www.w3.org/2002/07/owl#Restriction phrase is reduced to "owl:Restriction" only, then the query results in 0 results. Is there something more one has to do with prefixes and named graphs?

Update... it seems that if a prefix is mentioned in object of a triplet then it isn't being converted. I had to swap in the two object strings to make this query work. The other instances of "owl:" are fine:

  var ifm_hasDataType = ' <http://www.semanticweb.org/damion/ontologies/IFM_ontology#hasDataType> '
  var owl_Restriction = ' <http://www.w3.org/2002/07/owl#Restriction> '

  var sparql = 'PREFIX ifm:<http://www.semanticweb.org/damion/ontologies/IFM_ontology#>\
  SELECT ?datumId ?myDataType \
   FROM NAMED <test> { GRAPH <test> { \
    ?datumId rdfs:subClassOf ?restriction.\
    ?restriction rdf:type '+owl_Restriction+'.\
    ?restriction owl:onProperty '+ifm_hasDataType+'.\
    ?restriction owl:onClass ?myDataType.\
}} LIMIT 100'

Regards,

Damion