NAME

RDF::YAML - RDF YAML parser and dumper

VERSION

This document describes version 0.11 of RDF::YAML, released October 22, 2003.

SYNOPSIS

# Get triples from a RDF/YAML file
$rdf = RDF::YAML->new;
$triples = $rdf->parse_file("input.yml");

# Declare namespaces
my %namespaces = ( 'rss' => 'http://purl.org/rss/1.0/' );
$rdf->set_namespaces( \%namespaces );

# Translate RDF/XML to RDF/YAML
my @triples = RDF::Simple::Parser->new->parse_rdf($xml_string);
$rdf->set_triples(\@triples);
$rdf->dump_file("output.yml");

# Add new triples to a RDF/YAML string
$rdf->parse_string($yaml_string);
$rdf->add_triples(\@triples);
$yaml_string = $rdf->dump_string;

DESCRIPTION

This module is a RDF/YAML parser/dumper; it can parse RDF/YAML files or strings, provide results as triples, and dump triples back to RDF/YAML format. It is only a thin wrapper around RDF::Simple::Parser::YAML and RDF::Simple::Serialiser::YAML.

Note that this is a proof-of-concept work; the RDF/YAML format used by this module is purely experimental, and may change without notice.

METHODS

new()

Constructor. Currently takes no parameters.

parse_file($file)

Parses a RDF/YAML file specified by $file. Returns an array reference to parsed triples, in the standard [ $subject, $predicate, $object ] format. This also replaces all triples and namespaces stored within the object.

parse_string($string)

Similar to parse_file, but parses RDF/YAML data from string.

dump_file($file)

Writes all triples stored in the object into a file specified by $file, in RDF/YAML format.

dump_string()

Similar to dump_file, but returns a RDF/YAML string instead.

get_triples()

Returns a reference to array of triples currently stored in this object.

set_triples(\@triples)

Takes a reference to array of triples and stores it in the object, replacing previous ones. If invoked with no arguments, clears the stored triples.

add_triples(\@triples)

Similar to set_triples, but adds to currently stored triples instead of replacing them.

get_ns()

Returns a hash reference of namespaces currently in use.

Default namespaces are the same as listed in RDF::Simple::Serialiser.

set_ns(\%namespaces)

Takes a hash reference to namespaces expressed as $qname => $uri pairs, and adds them to subsequent RDF/YAML documents. This overrides (but does not clear) the default ones.

add_ns(\%namespaces)

Similar to set_ns, but adds to currently stored namespaces instead of replacing them.

SEE ALSO

RDF::Simple::Parser::YAML, RDF::Simple::Serialiser::YAML

YAML, RDF::Simple, RDF::Notation3

AUTHORS

Autrijus Tang <autrijus@autrijus.org>

COPYRIGHT

Copyright 2003 by Autrijus Tang <autrijus@autrijus.org>.

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

See http://www.perl.com/perl/misc/Artistic.html