Query trouble

1 view
Skip to first unread message

Chris Wallace

unread,
May 4, 2010, 7:38:01 PM5/4/10
to Data Incubator
I'm having some odd problems with a datastore I loaded this evening
with more election data.

http://api.talis.com/stores/cwallace-dev3/services/sparql

I uploaded 3 RDF/XML documents - getting a 204 each time - I can't see
from the API documentation what that means, but the data seems to be
up there OK

However queries which bind or FILTER on literals are empty :

This query gets Parties and their names correctly

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX : <http://www.cems.uwe.ac.uk/xmlwiki/rdf/election/vocab#>
PREFIX xs: <http://www.w3.org/2001/XMLSchema#>
select * where {
?party rdf:type :Party;
:party-name ?name.
}

this should select just Labour:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX : <http://www.cems.uwe.ac.uk/xmlwiki/rdf/election/vocab#>
PREFIX xs: <http://www.w3.org/2001/XMLSchema#>
select * where {
?party rdf:type :Party;
:party-name "Labour".
}

or maybe

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX : <http://www.cems.uwe.ac.uk/xmlwiki/rdf/election/vocab#>
PREFIX xs: <http://www.w3.org/2001/XMLSchema#>
select * where {
?party rdf:type :Party;
:party-name "Labour"^^xs:string.
}

but both are empty. I'm puzzled.

ps: Here is a link to the full set of documents used in the conversion

--
You received this message because you are subscribed to the Google Groups "Data Incubator" group.
To post to this group, send email to datain...@googlegroups.com.
To unsubscribe from this group, send email to dataincubato...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dataincubator?hl=en.

Chris Wallace

unread,
May 5, 2010, 2:37:36 AM5/5/10
to Data Incubator
Ahha, my problem was defining the data type of a literal as

rdf:datatype="xs:string"

rather than

rdf:datatype="http://www.w3.org/2001/XMLSchema#string"

The corrected data has been loaded into another datastore

http://api.talis.com/stores/cwallace-dev2/services/sparql

and the second query form now works.

Still I wonder what the best policy is with datatypes - specifying
them means that queries have to define the data type when binding
select * where {
?party rdf:type :Party;
:party-name "Labour"^^xs:string.

but not when filtering
select * where {
?party rdf:type :Party;
:party-name ?name.
FILTER (?name = "Labour")

so presumably the recommended policy is to omit the data type for
strings but how about integers and decimals - is it good practice to
define the datatypes or not (perhaps one for SematicOverflow)

Chris

Keith Alexander

unread,
May 5, 2010, 3:46:59 AM5/5/10
to datain...@googlegroups.com
> so presumably the recommended policy is to omit the data type for
> strings but how about integers and decimals - is it good practice to
> define the datatypes or not (perhaps one for SematicOverflow)

Aside from making queries a bit more complicated, a big disadvantage
with defining a datatype for natural language strings is that you
can't give them language tags (this restriction may be an advantage
for non-natural language strings like ID codes - though arguably it
would be better to define a more specific datatype).

The pedantic web mailing list discussed this a while back:
http://groups.google.com/group/pedantic-web/browse_thread/thread/7365cf5d58f6ea3b/976a0b35d9ff61e8?lnk=gst&q=datatypes#976a0b35d9ff61e8

With regards other datatypes, I'm not sure what the arguments around
best practice are. You can cast values as (some) xsd: datatypes in
sparql for the purposes of query without them needing to have that
explicit datatype in the data. The property definition might also have
a rdfs:range of a datatype, in which case all values of that property
can be inferred to be of that datatype. If the property definition
doesn't define the datatype of its values, it can be useful to do it
in the data to differentiate between other values of the same property
with a different datatype. Eg, if the values in your data for
ex:start are valid xsd:dateTime and some other data has values for
ex:start that are valid xsd:date, then adding datatypes to your data
helps keeps things a little cleaner, and makes it easier for
applications to know how to process the values.

Keith

Chris Wallace

unread,
May 5, 2010, 5:20:43 AM5/5/10
to Data Incubator
Thanks Keith

I see this is a recurring subject - I found some blogs by Leigh and
Jeni too

http://www.ldodds.com/blog/2009/08/rdf-data-typing/
http://www.jenitennison.com/blog/node/120

and the beginnings of a section in Leigh's Linked Data Patterns
http://patterns.dataincubator.org/book/linked-data-patterns.pdf

Chris


On May 5, 8:46 am, Keith Alexander <k.j.w.alexan...@gmail.com> wrote:
> > so presumably the recommended policy is to omit the data type for
> > strings but how about integers and decimals - is it good practice to
> > define the datatypes or not (perhaps one for SematicOverflow)
>
> Aside from making  queries a bit more complicated, a big disadvantage
> with defining a datatype for natural language strings is that you
> can't give them  language tags (this restriction may be an advantage
> for non-natural language strings like ID codes - though arguably it
> would be better to define a more specific datatype).
>
> The pedantic web mailing list discussed this a while back:http://groups.google.com/group/pedantic-web/browse_thread/thread/7365...
Reply all
Reply to author
Forward
0 new messages