title: Sparql- Select query as input and transform it into "Construct "query.?
body: <p>Im doing small task on Sparql and Jena. Basically I have to write a code that take any "select" query as input and Transform it into "Construct" Query.</p>
  
  <p>It should be done through Java Code.</p>
  
  <p>I have good understanding on "select" query and "construct" query. But this task confuses me. I'm doing simple sparql query only. Can anyone help me with this?</p>
  
  <pre><code>    // Select films and actors that appeared leonardo di caprio films // 
  
      "Prefix dbo: &lt;http://dbpedia.org/ontology/&gt;"
                  + "Prefix dbr: &lt;http://dbpedia.org/resource/&gt;"
                  + "select ?film ?actor where {\r\n" + 
                  "\r\n" + 
                  "?film a dbo:Film .\r\n" + 
                  "?film dbo:starring ?actor.\r\n" + 
                  "?film dbo:starring dbr:Leonardo_DiCaprio\r\n" + 
                  "\r\n" + 
                  "}";
  
  String service1 = "https://dbpedia.org/sparql"; // for select query 
  
  Query query = QueryFactory.create(query1); 
  
          QueryExecution qe = QueryExecutionFactory.sparqlService(service1,
                  query);
  
           ResultSet results = qe.execSelect(); 
  
  
  
  
           while (results.hasNext()){
               QuerySolution s=results.nextSolution();
               System.out.println(s);  
  
           }
  </code></pre>
  
  <p>The output will display the results for select query but for this task, I want to write  java code that take any "Select" query as input and transform it into "Construct" query(Not result). The construct query should display in the output for example.</p>
  
  <pre><code>OUTPUT:
  
  Construct {?actor &lt;Mov:Starring&gt; ?film.}
  Where {
  ?film a dbo:Film . 
  ?film dbo:starring ?actor.
  ?film dbo:starring dbr:Leonardo_DiCaprio
  }
  </code></pre>
  
  <p>Is there a way to do that. Can anyone help me?</p>