I'm trying this solution out now. It seems to run the query, but then I get this exception:
Caused by: java.io.IOException: Nodes of type 'object' are not supported in XCC result sequences at com.marklogic.xcc.impl.AbstractResultSequence.nodeFactory(AbstractResultSequence.java:237) at com.marklogic.xcc.impl.AbstractResultSequence.instantiateResultItem(AbstractResultSequence.java:191) at com.marklogic.xcc.impl.CachedResultSequence.<init>(CachedResultSequence.java:56) at com.marklogic.xcc.impl.handlers.GoodQueryResponseHandler.handleResponse(GoodQueryResponseHandler.java:48) at com.marklogic.xcc.impl.handlers.EvalRequestController.serverDialog(EvalRequestController.java:83) at com.marklogic.xcc.impl.handlers.AbstractRequestController.runRequest(AbstractRequestController.java:86) ... What does this mean and any suggestions on how to fix it? thanks, marc On Thu, Jun 5, 2014 at 1:49 PM, Michael Blakeley <[email protected]> wrote: > You could call https://docs.marklogic.com/sem:sparql through an XCC > moduleInvoke, something like this: > > xquery version "1.0-ml"; > (: sparql.xqy :) > import module namespace sem="http://marklogic.com/semantics" > at "/MarkLogic/semantics.xqy" ; > (: Add more variables to support bindings, etc. as needed :) > declare variable $SPARQL as xs:string external ; > sem:sparql($SPARQL) > (: end :) > > Then in Java: > > Session session = contentSource.newSession("mydatabase"); > Request request = session.newModuleInvoke("sparql.xqy"); > request.setNewStringVariable('SPARQL', mySparqlQuery); > // add more variables to support bindings, etc. as needed. > ResultSequence rs = session.submitRequest(request); > while (rs.hasNext()) { > ResultItem item = rs.next(); > // handle the item > } > session.close(); > > Wrap that up in a utility class, parameterize it as needed, and you'll > never have to think about it again. > > -- Mike > > On 5 Jun 2014, at 09:43 , Marc Limotte <[email protected]> wrote: > > > Hi. > > > > I'd like to run a SPARQL query from Java. I've found various bits of > documentation (including > http://developer.marklogic.com/learn/semantics-exercises/sparql-101). > But the docs all seem to cover running SPARQL from the console or maybe > REST or Xquery. Can someone point me in the right direction for running a > SPARQL query in Java? > > > > I don't need detailed instructions, just an overview or a pointer to the > right documentation. > > > > thanks for any help, > > Marc > > > > _______________________________________________ > > General mailing list > > [email protected] > > http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general >
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
