There isn't any better way if the list is being buiolt by teh query. If it is finding a list then ...

If your query is local, the app can query to find the head of the list then use the API and work with an RDFList

If it's remote, then find use of the use of the list (one query) and do a DESCRIBE for that resource may work. The default DESCRIBE algorithm is forward-blank node closure which will capture a list that uses blank nodes.

Neither is elegant.

    <x:s> <x:p> ( 1 2 ( 3 4 ) ).

then

   DESCRIBE <x:s>  {}

(Various caveats)

Without lists being a part of the SPARQL data model, (and paths) it's messy.

    Andy

On 04/09/2019 21:41, ajs6f wrote:
I'm not sure there is. There is not a simple way to parse one quad:

https://lists.apache.org/thread.html/a5c19bbe44109e4812f302462840569971aa732d73397bb8c2182aba@%3Cusers.jena.apache.org%3E

But perhaps there is, because I'm not very familiar with the output of 
RDFNode.toString(). In fact, I'm not sure how well-defined it is. Our Javadoc 
on the override of toString in RDFNode is documented thusly:

Answer a String representation of the node. The form of the string  depends on 
the type of the node and is intended for human consumption, not machine 
analysis.

which doesn't imply a good fit for your case. If possible you might want to 
think about working from something like Turtle, which can be concise for the 
case of many triples with the same subject and predicate but different objects:

https://www.w3.org/TR/turtle/#h3_object-lists

ajs6f

On Sep 4, 2019, at 5:42 AM, Martin G. Skjæveland <[email protected]> 
wrote:

Hi all,

in my application there is special support for lists (without going into further detail), 
and I would like to be able to have SPARQL queries that return lists. Since this is not 
supported in SPARQL, my idea is to exploit and consider GROUP_CONCAT "columns" 
in SPARQL result sets as lists and split and parse these part of the split to an RDFList 
(of RDFNodes).

Does this sound reasonable? Is there parsing functionality in Jena to handle 
this already? Perhaps there is something like  RDFNode parse(String)  which 
parses strings on the same format as RDFNode.toString() would produce back to 
an RDFNode?

Thanks!

Martin

Reply via email to