Element Transform Apache Jena

63 views Asked by At

I have a query like this:

SELECT  ?r ?r1 ?r2 ?r3 ?r4
WHERE
  { ?r  ?r1  ?r2 ;
        ?r3  ?r4
  }

I want to transform every triple with a optional element like:

SELECT  ?r ?r1 ?r2 ?r3 ?r4 ?r5
WHERE
  { {?r  ?r1  ?r2 .} OPTIONAL {?r ?r1 ?r5 .}
    {?r   ?r3  ?r4 .} OPTIONAL {?r ?r3 ?r5 .}
  }

basically i am trying to visit all ElementPathBlock, find a triple and transform it into :

{?r ?r1 ?r2 .} transform into {?r ?r1 ?r2 .} OPTIONAL {?r ?r1 ?r5 .}

But I cannot modify an Element while visiting it. Is there a way to do it in Jena?

0

There are 0 answers