#include everything Rob says about CONSTRUCT queries.

1/
But also the JSON results set parser has a bug in it - it is reading the link field as a string, but it should be an array.

This is now fixed in SVN.  The development snapshot build has the fix in it.

https://repository.apache.org/content/repositories/snapshots/org/apache/jena/apache-jena/

2/
But I think the data has problems as well:

For example:

"s": { "type": "uri" , "value": "_:vb43419" }

That looks like it is meant to be a bNode not a URI. It is illegal as a URI because there is no "_" URI scheme name and scheme names are only letters, digits, plus ("+"), period ("."), or hyphen ("-").

"s": { "type": "bnode" , "value": "_:vb43419" }

        Andy

PS For testing, ARQ has a command line tool arq.rset for reading and writing result sets.


On 26/06/12 00:35, Rob Vesse wrote:
Hi Lorena

JenaReaderRdfJson is for reading a JSON serialization of RDF.   The
serialization you are trying to read is the JSON serialization of SPARQL
Results which is completely different.

I notice you say that you use a CONSTRUCT query but the results you show
are the SPARQL Results JSON format which should only be used for
ASK/SELECT queries.  If Virtuoso is replying with that to your CONSTRUCT
query then they are behaving incorrectly and you should report a bug to
them.

If you genuinely expect SPARQL results instead then use
ResultSetFactory.fromJSON() which will give you a ResultSet object.

Rob


On 6/25/12 3:14 PM, "lorena" <[email protected]> wrote:

Hi:

I'm trying to process the results of performing a CONSTRUCT query on
Virtuoso using apache-jena-2.7.0-incubating
[1] shows the JSON String I would like to read (schemaStr).

Here is an extract of my code:

SysRIOT.wireIntoJena();
Model modelSchema = ModelFactory.createDefaultModel();
RDFReader schemaReader = new JenaReaderRdfJson() ;

StringReader s = new StringReader(schemaStr);
schemaReader.read(modelSchema, s, "");

And I receive the following exception caused in the line that executes
the read:

com.hp.hpl.jena.shared.JenaException: org.openjena.riot.RiotException:
[line: 2, col: 3 ] Relative IRI: head
        at
org.openjena.riot.system.JenaReaderRIOT.readImpl(JenaReaderRIOT.java:150)
        at org.openjena.riot.system.JenaReaderRIOT.read(JenaReaderRIOT.java:54)
        ....................



It seems to have trouble reading the "head" section.
My questions:
Is Virtuoso JSON output compatible with what JenaReaderRdfJson expects to
read?
Am I missing something else?
I'm using the empty string ("") as base URI in the read method, but I
don't understand what is the read method expecting in this field.

Thanks in advance
Lorena



[1]
{ "head": { "link": [], "vars": [ "s", "p", "o" ] },
  "results": { "distinct": false, "ordered": true, "bindings": [
    { "s": { "type" : "uri", "value" : "_:vb43419" }  , "p": { "type" :
"uri", "value" : "http://purl.org/olap#hasAggregateFunction"; }    , "o":
{ "type" : "uri", "value" : "http://purl.org/olap#sum"; }},
    { "s": { "type" : "uri", "value" : "_:vb43418" }  , "p": { "type" :
"uri", "value" : "http://purl.org/olap#level"; }   , "o": { "type" :
"uri", "value" : "http://example.org/householdCS#year"; }},
    { "s": { "type" : "uri", "value" :
"http://example.org/householdCS#household_withoutGeo"; }       , "p": {
"type" : "uri", "value" : "http://purl.org/linked-data/cube#component";
}       , "o": { "type" : "uri", "value" : "_:vb43418" }},
    { "s": { "type" : "uri", "value" :
"http://example.org/householdCS#household_withoutGeo"; }       , "p": {
"type" : "uri", "value" : "http://purl.org/linked-data/cube#component";
}       , "o": { "type" : "uri", "value" : "_:vb43419" }},
    { "s": { "type" : "uri", "value" : "_:vb43419" }  , "p": { "type" :
"uri", "value" : "http://purl.org/linked-data/cube#measure"; }     , "o": {
"type" : "uri", "value" : "http://example.org/householdCS#household";
}},
    { "s": { "type" : "uri", "value" :
"http://example.org/householdCS#householdCS"; }        , "p": { "type" :
"uri", "value" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"; }      ,
"o": { "type" : "uri", "value" :
"http://purl.org/linked-data/cube#DataStructureDefinition"; }} ] } }



Reply via email to