Hi Frank Interesting bug, have you considered publicising this more widely e.g. via the [email protected] list since I suspect many other libraries may encounter the same issue.
You could just provide the sample input as NTriples and then developers/users can check whether their libraries have the issue and take appropriate steps to get it fixed elsewhere. I have already reproduced and fixed this issue in my own library's Turtle Writer so I'll echo Andy's sentiment in saying thanks for a clear test case. Took me only a minute to code up the equivalent in my library and confirm the problem. Rob > -----Original Message----- > From: Andy Seaborne [mailto:[email protected]] > Sent: 22 March 2011 08:22 > To: [email protected] > Subject: Re: Problem with "Turtle" output? > > > Is this a bug > > Yes - I've raised JENA-55 with your example code as the test case. > > Pretty printing Turtle requires a prepass over the data to find lists > that can't written prettily in the (...) form. It should exclude lists > where one or more of the cons-cells making up the list has a URI. This > is a very unusual case; it takes some effort to create a list not > comprised of blank node cons-cells (there are the Jena API operations > for lists). In syntax, you have to write the list out long form - no > short form syntax enables this in Turtle). > > Thanks, and thanks for a clear test case, > > Andy > > https://issues.apache.org/jira/browse/JENA-55 > > > On 21/03/11 22:08, Frank Budinsky wrote: > > > > > > Hi, > > > > I created an rdf:list with named list entries, but when I call > Model.write > > ("Turtle") it seems to ignore the names and generates the simple "( > ... )" > > list syntax. Here's a test program that illustrates the problem: > > > > Model model = ModelFactory.createDefaultModel(); > > Resource data1 = model.createResource(); > > > data1.addProperty(model.createProperty("http://property"), > > "test1"); > > Resource data2 = model.createResource(); > > > data2.addProperty(model.createProperty("http://property"), > > "test2"); > > > > Resource listEntry1 = > model.createResource("http://test/1"); > > model.add(listEntry1, RDF.first, data1); > > model.add(listEntry1, RDF.rest, RDF.nil); > > > > Resource listEntry2 = > model.createResource("http://test/2"); > > model.add(listEntry2, RDF.first, data2); > > model.add(listEntry2, RDF.rest, listEntry1); > > > > Resource root = model.createResource("http://root"); > > root.addProperty(model.createProperty("http://list"), > > listEntry2); > > > > model.write(System.out, "N-TRIPLE"); > > model.write(System.out, "Turtle"); > > > > The output looks like this: > > > > _:AX2dX96d4dd4X3aX12eda6ae213X3aXX2dX7fff<http://property> "test1" . > > <http://root> <http://list> <http://test/2> . > > <http://test/2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> > > <http://test/1> . > > <http://test/2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> > > _:AX2dX96d4dd4X3aX12eda6ae213X3aXX2dX7ffe . > > _:AX2dX96d4dd4X3aX12eda6ae213X3aXX2dX7ffe<http://property> "test2" . > > <http://test/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> > > <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> . > > <http://test/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> > > _:AX2dX96d4dd4X3aX12eda6ae213X3aXX2dX7fff . > > <http://root> > > <http://list> ([<http://property> "test2" > > ] [<http://property> "test1" > > ]) . > > > > The "N-TRIPLE" output is as expected, but the "Turtle" output has > discarded > > the entry URIs. > > > > Is this a bug? > > > > Thanks, > > Frank
