On 14/05/14 12:38, Alejandro Rodríguez González wrote:
Hi!

Sorry if this question has been already answered. Based on a previous query
to this list ( http://goo.gl/kfKMqP ) now I have a small problem.

I have the same query and the following code (see query and code here:
http://pastebin.com/16B6MPmz ).

My problem is that, if I execute this query manually against the endpoint
(see: http://goo.gl/RVWuSi ) I can get correctly the desired result (a
datatype). However, doing this by code, I got the QuerySolution object
(which contains the variable name (dt) and the datatype (xml:string)), but
I can't get the datatype from the QuerySolution object.

If I try calling getResource(variable) method, it returns null. If I do the
same with the getLiteral(variable) or get(variable) to get a RDFNode,
always it returns a null value. Now, I'm getting the value parsing the
toString() value of the QuerySolution object, but I'm wondering if it is an
easier way to do that, or maybe I'm not using the correct classes/methods.

Thanks!


There's a bug in the CSV result reader but the CSV results format is not what you want.

The variable has been called "dt" including the quotes.

The CSV results format is not what you want because it is not a faithful syntax for the result set. It can't distinguish URIs from strings, for example.

That's why there is no ResultSetFactory.fromCSV function.

The code for teh CSv result set reader actually says:
   // This code exists to support the SPARQL WG tests.

To get a result form that is parseable, use one of the other forms.

(We should take "text/csv" out of the legal options.)

Except that endpoint seem broken or having a bad day or something - if I try any other format I get a HTTP error and body message:

2014-05-14 15:45:15 ERROR 500: SPARQL Request Failed.

even that is wrong because

  Content-Type: text/plain
  Content-Length: 669

and I don't get 669 bytes.

(this is using wget - no Jena code involved!)

        Andy
---------------------
X=$(cat <<EOF
SELECT distinct (datatype(?o) as ?dt)
FROM <http://bio2rdf.org/bio2rdf.dataset:bio2rdf-affymetrix-20131220>
WHERE {
?s a <http://bio2rdf.org/affymetrix_vocabulary:Probeset> .
?s <http://purl.org/dc/terms/identifier> ?o .
FILTER isLiteral(?o)
}
group by ?o
EOF
)

#FMT="application/sparql-results+json"
FMT="application/sparql-results+xml"
#FMT="text/csv"
wget -S -O- --header "Accept: $FMT"  \

"http://s4.semanticscience.org:14001/sparql?default-graph-uri=&query=$X";
---------------------

Reply via email to