You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Frank Budinsky <fr...@ca.ibm.com> on 2011/03/21 23:08:12 UTC

Problem with "Turtle" output?


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

Re: Problem with "Turtle" output?

Posted by Andy Seaborne <an...@epimorphics.com>.
Fix applied to Jena CVS on SF.  test added.

It will print in abbreviated form the tail of the list is valid short 
form (bnodes, only one rdf:rest, rdf:first per element), even if the 
head isn't acceptable.

	Andy

On 22/03/11 10:26, Rob Vesse wrote:
> Hi Frank
>
> Interesting bug, have you considered publicising this more widely e.g. via
> the semantic-web@w3.org 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:andy.seaborne@epimorphics.com]
>> Sent: 22 March 2011 08:22
>> To: jena-users@incubator.apache.org
>> 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
>

RE: Problem with "Turtle" output?

Posted by Frank Budinsky <fr...@ca.ibm.com>.
Hi Rob,

I'm not subscribed to any other RDF mailing list myself, but feel free to
forward this issue and example N-Triples to any mailing list that you think
might benefit.

Thanks,
Frank.

"Rob Vesse" <ra...@ecs.soton.ac.uk> wrote on 03/22/2011 06:26:09 AM:

> [image removed]
>
> RE: Problem with "Turtle" output?
>
> Rob Vesse
>
> to:
>
> jena-users
>
> 03/22/2011 06:27 AM
>
> Cc:
>
> Frank Budinsky
>
> Please respond to jena-users
>
> Hi Frank
>
> Interesting bug, have you considered publicising this more widely e.g.
via
> the semantic-web@w3.org 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:andy.seaborne@epimorphics.com]
> > Sent: 22 March 2011 08:22
> > To: jena-users@incubator.apache.org
> > 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
>

RE: Problem with "Turtle" output?

Posted by Rob Vesse <ra...@ecs.soton.ac.uk>.
Hi Frank

Interesting bug, have you considered publicising this more widely e.g. via
the semantic-web@w3.org 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:andy.seaborne@epimorphics.com]
> Sent: 22 March 2011 08:22
> To: jena-users@incubator.apache.org
> 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


Re: Problem with "Turtle" output?

Posted by Andy Seaborne <an...@epimorphics.com>.
 > 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