Andy,

Thanks for your response. I tried your suggestion, and unfortunately I'm getting the same result.

I looked for clojure libraries in this area, but didn't find any. If none are around when I've gotten up to speed, I'd look forward to contributing one.

Thanks for your help,

On 08/11/2011 11:46 AM, Andy Seaborne wrote:
Eric,

Clojure's fine.

> UpdateAction.execute (request, model);

All SPARQL Update works on graph stores (mutable datasets).

That operation creates a dataset and makes the model the default graph.

INSERT DATA INTO <http://example/bookStore>  { ... }

tries to add into the named graph. But because you passed in a model (container of triples), there is no second container for named graph <http://example/bookStore>.

You can create such a second graph with

CREATE GRAPH <http://example/bookStore> ;

but it will be inaccessible after the change because your code only has a model reference.

Try

  Dataset ds = DatasetFactory.create() ;
  UpdateRequest request = UpdateFactory.create(
       "CREATE GRAPH <g> ; \n"+
       "INSERT DATA { GRAPH <g> { <s> <p> <o> }}");
  UpdateAction.execute (request, ds);
  System.out.println(ds.asDatasetGraph()) ;

It might be better to change behavior and automatically create graphs, no CREATE GRAPH would be needed (TDB does not need CREATE GRAPH) butin your case it would lead to the change happening then not being accessible, which is strange.

About Clojure:

What would be good is to have an API to SPARQl or anything else in jena which is written in idiomatic clojure (scala, etc etc) Do know of such a thing or can you contribute one?

    Andy

On 11/08/11 19:00, Eric Scott wrote:
When I use your command line arguments I get exactly your results. The
fact remains that it's not happening in my program. My program is in
clojure, but the same code is being used for the query that works and
the query that doesn't, so I can't see what difference that would make.

Pseudocode:

model = ModelFactory.createDefaultModel ();

request = UpdateFactory.create();

request.add (sparqlString);

UpdateAction.execute (request, model);


Thanks,

On 08/11/2011 10:16 AM, Andy Seaborne wrote:


On 11/08/11 17:50, Eric Scott wrote:
Hi all -

When I execute this query (taken verbatim from
http://www.w3.org/Submission/SPARQL-Update/):

"PREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT DATA INTO <http://example/bookStore>
{ <http://example/book3> dc:title \"Fundamentals of Compiler Design\" }
"

Unrelated: INTO not going to be strict SPARQL 1.1 Update:

INSERT DATA
{ GRAPH <http://example/bookStore>
{ <http://example/book3> dc:title "Fundamentals of Compiler Design" }
}

The update submission is superseded by SPARQL 1.1


I get a null pointer exception in this context:

0:
com.hp.hpl.jena.sparql.core.DatasetGraphCollection.add(DatasetGraphCollection.java:27)


1:
com.hp.hpl.jena.sparql.core.DatasetGraphWrapper.add(DatasetGraphWrapper.java:57)


2:
com.hp.hpl.jena.sparql.modify.UpdateEngineWorker.visit(UpdateEngineWorker.java:215)


3:
com.hp.hpl.jena.sparql.modify.request.UpdateDataInsert.visit(UpdateDataInsert.java:15)


4:
com.hp.hpl.jena.sparql.modify.UpdateEngineMain.execute(UpdateEngineMain.java:28)


5:
com.hp.hpl.jena.sparql.modify.UpdateProcessorBase.execute(UpdateProcessorBase.java:48)


6: com.hp.hpl.jena.update.UpdateAction.execute$(UpdateAction.java:319)
7: com.hp.hpl.jena.update.UpdateAction.execute(UpdateAction.java:312)
8: com.hp.hpl.jena.update.UpdateAction.execute(UpdateAction.java:272)
9: com.hp.hpl.jena.update.UpdateAction.execute(UpdateAction.java:226)

This happens whether or not I precede the query with this:

"CREATE GRAPH <http://example/bookstore>"

Here's a minimal pairing that works just fine:

"PREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT DATA
{ <http://example/book3> dc:title \"Fundamentals of Compiler Design\" }
"

Is there something else I need to do?

Versions: Jena 2.6.4, arq 2.8.8.

Eric,

I tried your example with ARQ 2.8.8:

java -cp 'lib/*' arq.update --dump --file ../../U.ru

where U.ru has:

-----------
PREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT DATA INTO <http://example/bookStore>
{ <http://example/book3> dc:title "Fundamentals of Compiler Design" }
-----------
java -cp 'lib/*' arq.update --version
==>
Jena: VERSION: 2.6.4
Jena: BUILD_DATE: 2010-12-12T16:56:15+0000
ARQ: VERSION: 2.8.8
ARQ: BUILD_DATE: 2011-04-21T10:12:50+0100

Might you have a second, old, copy of ARQ, on your system?

How are you invoking the operation/ Specifically, are you passing in a
model or a dataset, and are you using in-memory storage?

Andy




Reply via email to