So far - one off list, two on-list and one [email protected] emails about this, all in less than 4 hours. :-)

On 15/06/11 16:53, Frank Budinsky wrote:


Hi,

I'm having a problem querying for rdfs:member predicates. Here is a test
program:

        public static void main( String[] args )
        {
                Dataset dataset = TDBFactory.createDataset();
                Model model = dataset.getDefaultModel();
                //PropertyFunctionRegistry.get().remove(RDFS.member.getURI()) ;
                String xml =
                        "<?xml version=\"1.0\"?>" +
                        "<rdf:RDF xmlns:rdf=
\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"; " +
                        "         xmlns:rdfs=
\"http://www.w3.org/2000/01/rdf-schema#\";>" +
                        "<rdf:Description rdf:about=
\"http://example.com/query\";>" +
                        "<rdfs:member rdf:resource=
\"http://example.com/bugs/5\"; />" +
                        "<rdfs:member rdf:resource=
\"http://example.com/bugs/4\"; />" +
                        "<rdfs:member rdf:resource=
\"http://example.com/bugs/3\"; />" +
                        "<rdfs:member rdf:resource=
\"http://example.com/bugs/2\"; />" +
                        "<rdfs:member rdf:resource=
\"http://example.com/bugs/1\"; />" +
                        "</rdf:Description>" +

Out of curiousity, why not use a container?

(OK - they aren't nice but then none of the datastructures are nice)

                        "</rdf:RDF>";
                model.read(new ByteArrayInputStream(xml.getBytes()), null);
                String queryString =
                        "PREFIX rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>  " +
                        "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>  " 
+
                        "SELECT ?resource ?member WHERE { " +
                        "   ?resource rdfs:member ?member " +
                        "   } ";

                Query query = QueryFactory.create(queryString);
                QueryExecution qexec = QueryExecutionFactory.create(query,
dataset);
                ResultSet result = qexec.execSelect();
                ResultSetFormatter.out(System.out, result, query);
                qexec.close();
        }

When I run it, I'm getting no results.

If I uncomment this line:

                //PropertyFunctionRegistry.get().remove(RDFS.member.getURI()) ;

then it returns the 5 expected results.

It seems that when rdfs:member inferencing is enabled, it no longer matches
concrete rdfs:member predicates. Is that not an ARQ bug?

There's no reason I can think of why it shouldn't also look for rdfs:member. Would you like to propose a patch? (it'll get done quicker that way)

See
... pfunction/function/container.java

(there is a small issue about cardinality of mixed use over rules but this does not really makes it worse or better)

An idiomatic trick is:

{ ?s ?p ?o . FILTER(?p = rdfs:member) }

and it scales, oddly, because identify optimization happens after property function spotting.

        Andy


Thanks,
Frank

Reply via email to