RDF::YAML - RDF YAML parser and dumper
This document describes version 0.11 of RDF::YAML, released October 22, 2003.
# 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;
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.
Constructor. Currently takes no parameters.
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.
[ $subject, $predicate, $object ]
Similar to parse_file, but parses RDF/YAML data from string.
parse_file
Writes all triples stored in the object into a file specified by $file, in RDF/YAML format.
$file
Similar to dump_file, but returns a RDF/YAML string instead.
dump_file
Returns a reference to array of triples currently stored in this object.
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.
Similar to set_triples, but adds to currently stored triples instead of replacing them.
set_triples
Returns a hash reference of namespaces currently in use.
Default namespaces are the same as listed in RDF::Simple::Serialiser.
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.
$qname => $uri
Similar to set_ns, but adds to currently stored namespaces instead of replacing them.
set_ns
RDF::Simple::Parser::YAML, RDF::Simple::Serialiser::YAML
YAML, RDF::Simple, RDF::Notation3
Autrijus Tang <autrijus@autrijus.org>
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
To install RDF::YAML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RDF::YAML
CPAN shell
perl -MCPAN -e shell install RDF::YAML
For more information on module installation, please visit the detailed CPAN module installation guide.