CC: | Ivan Shmakov <oneingray [...] gmail.com> |
Subject: | property paths going crazy? |
Date: | Thu, 04 Nov 2010 18:14:21 +0600 |
To: | bug-RDF-Query [...] rt.cpan.org |
From: | Ivan Shmakov <ivan [...] main.uusia.org> |
[Versions: RDF-Query-2.902.tar.gz, with RDF-Trine-0.130.tar.gz.]
Following the example in [1], I'm trying to SELECT all the
elements of the ex:odd list from the following dataset:
--cut--
@base <x-dummy:uri> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ex: <http://example.com/#> .
ex:odd rdf:value (1 3 5 7) .
ex:even rdf:value (2 4 6 8) .
--cut--
My query is:
--cut--
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://example.com/#>
SELECT ?elt
WHERE {
ex:odd rdf:value/rdf:rest*/rdf:first ?elt .
}
--cut--
Contrary to my expectations, I get a whole lot of results,
including the elements of /both/ lists, and not just ex:odd! (A
simplistic wrapper over RDF::Query, rdf-query.pl, is MIME'd.)
$ perl rdf-query.pl data.turtle "$(cat < query.sparql)"
elt "1"^^<http://www.w3.org/2001/XMLSchema#integer>
elt "3"^^<http://www.w3.org/2001/XMLSchema#integer>
elt "5"^^<http://www.w3.org/2001/XMLSchema#integer>
elt "6"^^<http://www.w3.org/2001/XMLSchema#integer>
## ... 1950 more results...
elt "8"^^<http://www.w3.org/2001/XMLSchema#integer>
elt "3"^^<http://www.w3.org/2001/XMLSchema#integer>
elt "4"^^<http://www.w3.org/2001/XMLSchema#integer>
elt "7"^^<http://www.w3.org/2001/XMLSchema#integer>
$
[1] http://www.w3.org/TR/sparql11-query/#propertypath-examples
--
FSF associate member #7257
### rdf-query-2010-11-04.pl -*- Perl -*-
use strict;
use warnings;
require RDF::Query;
require RDF::Trine::Model;
require RDF::Trine::Store::Memory;
die ("Usage: rdf-query-2010-11-04 TURTLE-FILE QUERY")
unless (1 + $#ARGV == 2);
my ($file, $sparql) = @ARGV;
my $store
= RDF::Trine::Store->new_with_config ({
"storetype" => "Memory",
"sources" => [
{
"file" => $file,
"syntax" => "turtle",
"base_uri" => "x-dummy:uri"
} ] });
my $model
= new RDF::Trine::Model ($store);
my $query
= RDF::Query->new ($sparql);
for (my $iterator = $query->execute ($model);
my $row = $iterator->next ();
) {
foreach my $k (keys (%$row)) {
print (" ", $k, " ", $row->{$k});
}
print ("\n");
}
## Local variables:
## fill-column: 72
## indent-tabs-mode: nil
## End:
### rdf-query-2010-11-04.pl ends here
Message body not shown because it is not plain text.