![]() |
![]()
| ![]() |
![]()
NAMERDF::Simple::Serialiser - convert a list of triples to RDF DESCRIPTIONA simple RDF serialiser. Accepts an array of triples, returns a serialised RDF document. SYNOPSISmy $ser = RDF::Simple::Serialiser->new( # OPTIONAL: Supply your own bNode id prefix: nodeid_prefix => 'a:', ); # OPTIONAL: Add your namespaces: $ser->addns( foaf => 'http://xmlns.com/foaf/0.1/', ); my $node1 = $ser->genid; my $node2 = $ser->genid; my @triples = ( ['http://example.com/url#', 'dc:creator', 'zool@example.com'], ['http://example.com/url#', 'foaf:Topic', '_id:1234'], ['_id:1234','http://www.w3.org/2003/01/geo/wgs84_pos#lat','51.334422'] [$node1, 'foaf:name', 'Jo Walsh'], [$node1, 'foaf:knows', $node2], [$node2, 'foaf:name', 'Robin Berjon'], [$node1, 'rdf:type', 'foaf:Person'], [$node2, 'rdf:type','http://xmlns.com/foaf/0.1/Person'] [$node2, 'foaf:url', \'http://server.com/NOT/an/rdf/uri.html'], ); my $rdf = $ser->serialise(@triples); ## Round-trip example: my $parser = RDF::Simple::Parser->new(); my $rdf = LWP::Simple::get('http://www.zooleika.org.uk/foaf.rdf'); my @triples = $parser->parse_rdf($rdf); my $new_rdf = $serialiser->serialise(@triples); METHODS
BUGSPlease report bugs via the RT web site <http://rt.cpan.org/Ticket/Create.html?Queue=RDF-Simple> NOTESThe original author was British, so this is a Serialiser. For American programmers, RDF::Simple::Serializer will work as an alias to the module, and serialize() does the same as serialise(). The distinction between a URI and a literal string in the "object" (third element) of each triple is made as follows: if the object is a reference, it is output as a literal; if the object "looks like" a URI (according to Regexp::Common::URI), it is output as a URI. THANKSThanks particularly to Tom Hukins, and also to Paul Mison, for providing patches. AUTHOROriginally written by Jo Walsh (formerly <jo@london.pm.org>). Currently maintained by Martin Thurn <mthurn@cpan.org>. LICENSEThis module is available under the same terms as perl itself.
|