The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

RDF::MicroTurtle::Context - contextual hints for parsing MicroTurtle

VERSION

0.001

DESCRIPTION

MicroTurtle is an unusual serialisation of RDF in that it provides various tokens representing people and tags/concepts which the parser expands to full URIs based on out-of-band contextual knowledge.

This module provides a safe, albeit not very good, default context. Better contexts should be written as subclasses of this one.

The constructor is called as:

  my $context = RDF::MicroTurtle::Context->new(%args);

All arguments are optional.

  • $args{'me_uri'} - the full URI that "<#me>" will be expanded to when parsing MicroTurtle.

  • $args{'agent_uri'} - the template URI that "@somebody" will be expanded to when parsing MicroTurtle. This is a string containing "%s" which will be used to substitute an account name.

  • $args{'tag_uri'} - the template URI that "#hashtag" will be expanded to when parsing MicroTurtle. This is a string containing "%s" which will be used to substitute a hash tag.

SUBCLASSING

Your new constructor may be passed various details about the context of the MicroTurtle data being parsed. It can pick and choose which details it wants to honour.

Two interesting arguments to the constructor are 'id' and 'model' which are an RDF::Trine::Node and RDF::Trine::Model respectively. These are passed by RDF::MicroTurtle::Feed and contain the identifier for the feed entry currently being parsed, and an RDF model of the RSS/Atom feed data itself.

The important methods to override are me_uri (returns a URI that represents the document author), agent_uri (takes an account name, and returns a URI representing the agent that holds the account), and tag_uri (takes a hashtag minus the hash, and returns a URI representing the concept that the hashtag denotes).

Other methods to override are agent_triples (takes an account name, and returns an array of RDF::Trine::Statemement objects describing the holder of the account), tag_triples (takes a hashtag minus the hash, and returns an array of RDF::Trine::Statement objects describing the concept denoted by the hashtag) and tagging_triples (takes a URI or bnode identifier - starting with '_:' - and a hashtag, and returns an array of triples to indicate that the thing identified by the URI or bnode has been tagged with that tag).

BUGS

Please report any bugs to http://rt.cpan.org/.

SEE ALSO

RDF::MicroTurtle::Parser.

http://www.perlrdf.org/.

http://buzzword.org.uk/2009/microturtle/spec.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

Copyright (C) 2009-2010 by Toby Inkster

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8 or, at your option, any later version of Perl 5 you may have available.