Notation 3 support

Gregory Williams greg at evilfunhouse.com
Mon Jul 5 16:07:03 CEST 2010


On Jul 4, 2010, at 5:18 PM, Toby Inkster wrote:

> I woke up this morning with a clear idea of how to add support for
> property paths. Implemented it this evening in less than 20 lines of
> code. The attached patch should now be able to parse Notation 3 fully.

Nice work.

> Next steps are an N3 serialiser, and then to clean it all up and release
> it all as a separate distribution on CPAN. (I plan on calling it
> "RDF::TriN3".)

That's almost too clever for its own good :)

> In the mean time, here's a Turtle serialisation bugette I've discovered.
> Create an RDF graph along these lines:
> 
> 	_:foo <#a> <#b> .
> 	<#c> _:foo <#d> .
> 
> It will be serialised something like this:
> 
> 	[] <#a> <#b> .
> 	<#c> _:r1234567890 <#d> .
> 
> Putting aside the fact that the second triple shouldn't be serialised
> in Turtle at all, as it's not legal RDF, the serialiser has lost the
> connection between the two appearances of the blank node.
> 
> I imagine when it decides to use '[]' rather than '_:something' to
> serialise a blank node, it first checks whether the node is the object
> of any triples - it doesn't check whether it's the predicate.

Yes, this is exactly why it won't serialize properly.

> There's a slightly bigger option of what to do when a serialiser tries
> to serialise a triple that cannot legally be represented in the format
> its outputting. I'd suggest there should be a constructor option along
> the lines of:
> 
> 	$s = RDF::Trine::Serializer->new('turtle', illegals=>'die');
> 
> Where 'illegals' can be set to 'die', 'warn', 'skip' or 'force'. If
> 'die' the serializer just dies when serialising something illegal; if
> 'warn' it issues a warning to STDERR and then skips the triple; if
> 'skip' it silently skips the triple; if 'force' it attempts to
> serialise the triple even if it means that the output is not strictly
> valid.

OK. I'm open to discussing changes like this. Right now all my stuff generally throws an exception via L<Error>, but I know there's some resistance to that since Error has been deprecated. I still haven't found a suitable replacement for my (subjective) needs, but could probably add in some alternative behaviors like those you suggest. What does anyone else think about these?

.greg



More information about the Dev mailing list