You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Ghinwa FAKIH <gi...@etu.univ-nantes.fr> on 2023/06/20 14:00:02 UTC

SPARQL-Star Parser

I hope this email finds you well. I'm writing to seek your assistance 
regarding a programming task I'm working on, specifically related to 
traversing nested triple patterns in SPARQL-star queries using the 
Apache Jena framework. Recently, I executed a code snippet that 
retrieves the query pattern from a SPARQL query using the Apache Jena 
library. The code checks if the query pattern is a group (represented by 
the ElementGroup class) and, if so, retrieves the individual elements of 
the group. For each element, it prints a string representation of the 
element using the toString() method.

However, when I ran the code, the output I received was in the format:

Element: << ?s ex:p1 ex:o1 >> ex:p2 ?o.

But this provides a partial view of the nested triple patterns, which 
does not meet my requirements. I am particularly interested in obtaining 
every individual triple or triple pattern within each level of nesting. 
Unfortunately, the output includes incomplete elements, such as |ex:p2 
?o|, which fails to capture the complete nested triple pattern.

I recognized that I need to use SPARQL-Star parser but in the github of 
Apache jena, I can only find the SPARQL parser and not the SPARQL-Star 
parser.

I would appreciate any help.

Thank you in advance

Kind Regards

Re: SPARQL-Star Parser

Posted by Andy Seaborne <an...@apache.org>.
On 20/06/2023 15:00, Ghinwa FAKIH wrote:
> I hope this email finds you well. I'm writing to seek your assistance 
> regarding a programming task I'm working on, specifically related to 
> traversing nested triple patterns in SPARQL-star queries using the 
> Apache Jena framework. Recently, I executed a code snippet that 
> retrieves the query pattern from a SPARQL query using the Apache Jena 
> library. The code checks if the query pattern is a group (represented by 
> the ElementGroup class) and, if so, retrieves the individual elements of 
> the group. For each element, it prints a string representation of the 
> element using the toString() method.
> 

Do you have an minimal, complete example?

> However, when I ran the code, the output I received was in the format:
> 
> Element: << ?s ex:p1 ex:o1 >> ex:p2 ?o.

So what was the original query?

> 
> But this provides a partial view of the nested triple patterns, which 
> does not meet my requirements. I am particularly interested in obtaining 
> every individual triple or triple pattern within each level of nesting. 
> Unfortunately, the output includes incomplete elements, such as |ex:p2 
> ?o|, which fails to capture the complete nested triple pattern.
> 
> I recognized that I need to use SPARQL-Star parser but in the github of 
> Apache jena, I can only find the SPARQL parser and not the SPARQL-Star 
> parser.

There isn't a separate parser. The default system has RDF-star support 
(the CG report).


> 
> I would appreciate any help.
> 
> Thank you in advance
> 
> Kind Regards
>