XML::Atom::OWL(3pm) | User Contributed Perl Documentation | XML::Atom::OWL(3pm) |
XML::Atom::OWL - parse an Atom file into RDF
use XML::Atom::OWL; $parser = XML::Atom::OWL->new($xml, $baseuri); $graph = $parser->graph;
This has a pretty similar interface to RDF::RDFa::Parser.
The $xml variable may contain an XML (Atom) string, or an XML::LibXML::Document object. If a string, the document is parsed using XML::LibXML, which will throw an exception if it is not well-formed. XML::Atom::OWL does not catch the exception.
The base URI is used to resolve relative URIs found in the document.
Currently only one option is defined, 'no_fetch_content_src', a boolean indicating whether <content src> URLs should be automatically fetched and added to the model as if inline content had been provided. They are fetched by default, but it's pretty rare for feeds to include this attribute.
$storage is an RDF::Trine::Storage object. If undef, then a new temporary store is created.
Optionally it may be passed a parameter - an absolute or relative URI - in which case it returns the same URI which it was passed as a parameter, but as an absolute URI, resolved relative to the document's base URI.
This seems like two unrelated functions, but if you consider the consequence of passing a relative URI consisting of a zero-length string, it in fact makes sense.
This method automatically calls "consume".
Calls "consume" automatically.
$p->set_callbacks({ 'pretriple_resource' => sub { ... } , 'pretriple_literal' => sub { ... } , 'ontriple' => undef , });
For details of the callback functions, see the section CALLBACKS. "set_callbacks" must be used before "consume". "set_callbacks" itself returns a reference to the parser object itself.
This function returns the parser object itself, making it easy to abbreviate several of XML::Atom::OWL's functions:
my $iterator = XML::Atom::OWL->new(undef, $uri) ->consume->graph->as_stream;
You probably only need to call this explicitly if you're using callbacks.
Several callback functions are provided. These may be set using the "set_callbacks" function, which taskes a hashref of keys pointing to coderefs. The keys are named for the event to fire the callback on.
This is called when a triple has been found, but before preparing the triple for adding to the model. It is only called for triples with a non-literal object value.
The parameters passed to the callback function are:
The callback should return 1 to tell the parser to skip this triple (not add it to the graph); return 0 otherwise.
This is the equivalent of pretriple_resource, but is only called for triples with a literal object value.
The parameters passed to the callback function are:
Beware: sometimes both a datatype and a language will be passed. This goes beyond the normal RDF data model.)
The callback should return 1 to tell the parser to skip this triple (not add it to the graph); return 0 otherwise.
This is called once a triple is ready to be added to the graph. (After the pretriple callbacks.) The parameters passed to the callback function are:
The callback should return 1 to tell the parser to skip this triple (not add it to the graph); return 0 otherwise. The callback may modify the RDF::Trine::Statement object.
Please report any bugs to <http://rt.cpan.org/>.
RDF::Trine, XML::Atom::FromOWL.
<http://www.perlrdf.org/>.
Toby Inkster <tobyink@cpan.org>.
Copyright 2010-2011 Toby Inkster
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2022-06-28 | perl v5.34.0 |