Github user hartig commented on the issue:

    https://github.com/apache/jena/pull/473
  
    > Where and how are you wanting to output text format?
    
    Where? In the command line tool for executing SPARQL* queries (see 
[`ExecuteSPARQLStar` in 
RDFstarTools](https://github.com/RDFstar/RDFstarTools/blob/master/src/main/java/se/liu/ida/rdfstar/tools/ExecuteSPARQLStar.java)).
    
    How? As it is done by the `TextOutput` class in Jena, plus added support 
for the case in which the `Node` for a variable is of type `Node_Triple` (which 
is possible in results of SPARQL* queries). In this case, the triple wrapped by 
that `Node_Triple` should be printed Turtle*-style, i.e., enclosed within `<<` 
and `>>`. I have already implemented the necessary extension of the 
`TextOutput` class: see [`TextOutputStar` in 
RDFstarTools](https://github.com/RDFstar/RDFstarTools/blob/master/src/main/java/se/liu/ida/rdfstar/tools/sparqlstar/resultset/TextOutputStar.java).
    
    > `QueryExecutils.outputResultSet` handles it - making 
`ResultSetFormatter.output(OutputStream, ResultSet, ResultsFormat)` could do 
the same (lookup properly for first-class results formats, and have some 
adapter code to handle the other ways) is one way. Would that work or you?
    
    Not really I think. I am indirectly using `QueryExecUtils.outputResultSet` 
already. That is, my command line tool for executing SPARQL* queries 
(`ExecuteSPARQLStar`) ends up in exactly that method, simply because 
`ExecuteSPARQLStar` extends `arq.query` (which uses 
`QueryExecUtils.executeQuery(Prologue, QueryExecution, ResultsFormat)`). Then, 
`QueryExecUtils.outputResultSet` calls `ResultSetFormatter.out(OutputStream, 
ResultSet, Prologue)`.
    The problem is that all of these are static methods and there is no way for 
me to specify which `TextOutput` object should be used by 
`ResultSetFormatter.out(OutputStream, ResultSet, Prologue)`. I want it to use 
my `TextOutputStar` (see above) instead of `TextOutput`.
    
    So, again, I think the easiest solution would be if my command line tool 
for executing SPARQL* queries (`ExecuteSPARQLStar`) could simply call a 
to-be-created method of `ResultsFormat` that allows my program to add something 
to `ResultsFormat.mapResultsFormatToLang`. Then, my program would simply add 
`ResultsFormat.FMT_TEXT` -> `ResultSetLang.SPARQLResultSetText` (which would be 
used only within the context of my program), and `ResultsWriter` would find and 
use my `ResultSetWriterFactory` (which is created and registered in 
[`ResultSetWritersSPARQLStar`](https://github.com/RDFstar/RDFstarTools/blob/master/src/main/java/se/liu/ida/rdfstar/tools/sparqlstar/resultset/ResultSetWritersSPARQLStar.java)).
 Hence, all that would be needed is to add the following code to the 
`ResultsFormat` class of Jena.
    ```
    public static void addResultsFormatToLangPair(ResultsFormat fmt, Lang lang) 
{
           mapResultsFormatToLang.put(fmt, lang) ;
    }
    ```
    I believe such a method can be helpful for other use cases as well (e.g., 
assume someone wants to introduce a new result format language). What do you 
say?


---

Reply via email to