Jakob Voß > Turtle-Writer-0.002 > Turtle::Writer

Download:
Turtle-Writer-0.002.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.002   Source   Latest Release: Turtle-Writer-0.004

NAME ^

Turtle::Writer - Write RDF/Turtle documents without non-core package dependencies

VERSION ^

version 0.002

SYNOPSIS ^

  use Turtle::Writer;

  say turtle_statement( 
    "<$uri>",
      "a" => "<http://purl.org/ontology/bibo/Document>",
      "dc:creator" => { # plain literals are escaped
                "" => [ "Terry Winograd", "Fernando Flores" ]
      },
      "dc:date" => { "xs:gYear" => "1987" }, # typed literal
      "dc:title" =>
          { en => "Understanding Computers and Cognition" },
      "dc:description" => undef,  # will be ignored
  );

DESCRIPTION ^

Turtle::Writer is a lightweight helper module for Perl programs that write RDF data in Turtle syntax. No non-core packages are required. Before directly writing RDF/Turtle by hand, have a look at this module. Before using this module, have a look at RDF::Trine::Serializer::Turtle which provides a full featured serializer for RDF data in Turtle syntax.

By default this module exports four methods: turtle_statement, turtle_literal, turtle_literal_list, and turtle_uri. This methods may be handy to directly create serialized RDF from other forms of structured data. Literal values are escaped and undef is ignored, among other features.

METHODS ^

turtle_statement ( $subject, $predicate => $object [, ... ] )

Returns a (set of) RDF statements in Turtle syntax. Subject and predicate parameters must be strings. Object parameters must either be strings or arrays of strings. This function strips undefined values and empty strings, but it does not further check or validate parameter values.

turtle_literal ( $string [ [ lang => ] $lang | [ type => ] $datatype ] )

Returns a literal string escaped in Turtle syntax. You can optionally provide either a language or a full datatype URI (but their values are not validated). Returns the empty string instead of a Turtle value, if $string is undef or the empty string.

turtle_literal_list ( $literal | @array_of_literals | { $language => $literal } )

Returns a list of literal strings in Turtle syntax.

turtle_uri ( $uri )

Returns an URI in Turtle syntax, that is "<$uri>". Returns the empty string, if $uri is undef, but <> if $uri is the empty string. In most cases you better directly write "<$uri>".

AUTHOR ^

Jakob Voss

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 by Jakob Voss.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: