> 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

Reply via email to