BalduinLandolt commented on issue #2083:
URL: https://github.com/apache/jena/issues/2083#issuecomment-1866277134
Hi, since I worked with @mpro7 on this, and I had some spare time to
reproduce it, let me provide additional information:
The following (admittedly nonsensical!) Scala code:
```scala
import org.apache.jena
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, InputStream,
OutputStream}
import java.nio.charset.StandardCharsets
import scala.util.Try
object Run extends App {
val ttl =
"""|
|@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|@prefix owl: <http://www.w3.org/2002/07/owl#> .
|@prefix knora-base: <http://www.knora.org/ontology/knora-base#> .
|
|<http://www.knora.org/ontology/0001/anything>
| rdf:type owl:Ontology ;
| rdfs:label "The anything ontology" ;
| knora-base:attachedToProject <http://rdfh.ch/projects/0001> ;
| knora-base:lastModificationDate
"2017-12-19T15:23:42.166Z"^^xsd:dateTime .
|
|""".stripMargin
val is = new ByteArrayInputStream(ttl.getBytes(StandardCharsets.UTF_8))
val os = new ByteArrayOutputStream()
StreamParser.parse(is, os)
val res = os.toString
println(res)
}
object StreamParser {
def parse(inputStream: InputStream, outputStream: OutputStream): Unit = {
val streamRDF = new jena.riot.system.StreamRDF {
val inner =
jena.riot.system.StreamRDFWriter.getWriterStream(outputStream,
jena.riot.RDFLanguages.TURTLE)
override def start(): Unit = inner.start()
override def finish(): Unit = inner.finish()
override def base(base: String): Unit = {}
override def prefix(prefix: String, iri: String): Unit =
inner.prefix(prefix, iri)
override def quad(quad: jena.sparql.core.Quad): Unit =
inner.quad(quad)
// ----- !!! here !!! -----
override def triple(triple: jena.graph.Triple): Unit =
inner.quad(jena.sparql.core.Quad.create(jena.sparql.core.Quad.defaultGraphIRI,
triple))
}
val parser = jena.riot.RDFParser.create()
parser.source(inputStream)
val parseTry: Try[Unit] = Try {
parser
.lang(jena.riot.RDFLanguages.TURTLE)
.errorHandler(jena.riot.system.ErrorHandlerFactory.errorHandlerStrictNoLogging)
.parse(streamRDF)
}
inputStream.close()
outputStream.close()
parseTry.get
}
}
```
when executed with Jena 4.8.0, produces
```
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix knora-base: <http://www.knora.org/ontology/knora-base#> .
<http://www.knora.org/ontology/0001/anything>
rdf:type owl:Ontology ;
rdfs:label "The anything ontology" ;
knora-base:attachedToProject <http://rdfh.ch/projects/0001> ;
knora-base:lastModificationDate
"2017-12-19T15:23:42.166Z"^^xsd:dateTime .
```
but with Jena 4.9.0 it outputs
```
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix knora-base: <http://www.knora.org/ontology/knora-base#> .
<urn:x-arq:DefaultGraph> {
<http://www.knora.org/ontology/0001/anything>
rdf:type owl:Ontology ;
rdfs:label "The anything ontology" ;
knora-base:attachedToProject <http://rdfh.ch/projects/0001> ;
knora-base:lastModificationDate
"2017-12-19T15:23:42.166Z"^^xsd:dateTime .
}
```
the interesting part is probably where the implementation of `StreamRDF`
implements `triple()` as `quad()` with default graph.
From the looks of it, in Jena 4.8 this produced TTL, while in Jena 4.9 it
seems to produce TRIG output.
I hope this information helps, and I apologise for providing Scala rather
than Java code (but it was painful enough to get to this reproduction of the
issue).
If you have any questions, please feel free to ask!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]