On 08/09/16 16:24, Andy Seaborne wrote:
The TSV format is the lossless form of you want that style of output.
                                      if

(sorry - especially bad typing day today)


    I am testing a very simple case with a ResultSet of just 4 rows.
    Using Jena 2.11.0

    Any thoughts?

Upgrade? 2.11 is quite old.

    Andy

On 08/09/16 14:42, Rob Vesse wrote:
The CSV format is explicitly defined to be a lossy format so some
information can and will be lost when serialising to CSV. Specifically
the datatypes and language tags for literals and literals/URIs may not
be distinguishable due to their encoding.

From the spec
(http://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-20130321/#intro):

The SPARQL Results CSV Results Format is a lossy encoding of a table
of results. It does not encode all the details of each RDF term in the
results but instead just gives a string without indicating the type of
the term (IRI, Literal, Literal with datatype, Literal with language,
or blank node). This makes it simple to consume data, such as text and
numbers, in applications without needing to understand the details of
RDF. In some applications, guesses as to which elements are hyperlinks
are made pragmatically, for example, guessing that strings starting
"http://"; are links.

Rob

On 08/09/2016 14:04, "Nikolaos Beredimas" <[email protected]> wrote:

    I have a method that does a SPARQL select query and returns
results in XML,
    JSON and CSV using
    outputAsCSV

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSetFormatter.html#outputAsCSV-java.io.OutputStream-org.apache.jena.query.ResultSet->

    (OutputStream

<http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true>

     outStream, ResultSet

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSet.html>

     resultSet)
    outputAsJSON

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSetFormatter.html#outputAsJSON-java.io.OutputStream-org.apache.jena.query.ResultSet->

    (OutputStream

<http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true>

     outStream, ResultSet

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSet.html>

     resultSet)
    outputAsXML

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSetFormatter.html#outputAsXML-java.io.OutputStream-org.apache.jena.query.ResultSet->

    (OutputStream

<http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true>

     outStream, ResultSet

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSet.html>

     qresults)

    When trying to unit test it I have a problem with the CSV case.
    I have tried
    ResultSetCompare

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/sparql/resultset/ResultSetCompare.html#ResultSetCompare-->

    .equalsByTerm

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/sparql/resultset/ResultSetCompare.html#equalsByTerm-org.apache.jena.query.ResultSet-org.apache.jena.query.ResultSet->

    (ResultSet

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSet.html>

     rs1, ResultSet

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSet.html>

     rs2)
    ResultSetCompare

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/sparql/resultset/ResultSetCompare.html#ResultSetCompare-->

    .equalsByValue

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/sparql/resultset/ResultSetCompare.html#equalsByValue-org.apache.jena.query.ResultSet-org.apache.jena.query.ResultSet->

    (ResultSet

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSet.html>

     rs1, ResultSet

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSet.html>

     rs2)
    ResultSetCompare

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/sparql/resultset/ResultSetCompare.html#ResultSetCompare-->

    .isomorphic

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/sparql/resultset/ResultSetCompare.html#isomorphic-org.apache.jena.query.ResultSet-org.apache.jena.query.ResultSet->

    (ResultSet

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSet.html>

     rs1, ResultSet

<https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ResultSet.html>

     rs2)
    and they all fail to return true.

    Compared ResultSet objects are converted to ResultSetRewindable
before
    comparing.
    JSON and XML cases work as expected (return true), but CSV fails.

    I am testing a very simple case with a ResultSet of just 4 rows.
    Using Jena 2.11.0

    Any thoughts?

    Nikos.






Reply via email to