1XML::Atom::OWL(3)     User Contributed Perl Documentation    XML::Atom::OWL(3)
2
3
4

NAME

6       XML::Atom::OWL - parse an Atom file into RDF
7

SYNOPSIS

9        use XML::Atom::OWL;
10
11        $parser = XML::Atom::OWL->new($xml, $baseuri);
12        $graph  = $parser->graph;
13

DESCRIPTION

15       This has a pretty similar interface to RDF::RDFa::Parser.
16
17   Constructor
18       "new($xml, $baseuri, \%options, $storage)"
19           This method creates a new XML::Atom::OWL object and returns it.
20
21           The $xml variable may contain an XML (Atom) string, or an
22           XML::LibXML::Document object. If a string, the document is parsed
23           using XML::LibXML, which will throw an exception if it is not well-
24           formed. XML::Atom::OWL does not catch the exception.
25
26           The base URI is used to resolve relative URIs found in the
27           document.
28
29           Currently only one option is defined, 'no_fetch_content_src', a
30           boolean indicating whether <content src> URLs should be
31           automatically fetched and added to the model as if inline content
32           had been provided. They are fetched by default, but it's pretty
33           rare for feeds to include this attribute.
34
35           $storage is an RDF::Trine::Storage object. If undef, then a new
36           temporary store is created.
37
38   Public Methods
39       "uri"
40           Returns the base URI of the document being parsed. This will
41           usually be the same as the base URI provided to the constructor.
42
43           Optionally it may be passed a parameter - an absolute or relative
44           URI - in which case it returns the same URI which it was passed as
45           a parameter, but as an absolute URI, resolved relative to the
46           document's base URI.
47
48           This seems like two unrelated functions, but if you consider the
49           consequence of passing a relative URI consisting of a zero-length
50           string, it in fact makes sense.
51
52       "dom"
53           Returns the parsed XML::LibXML::Document.
54
55       "graph"
56           This method will return an RDF::Trine::Model object with all
57           statements of the full graph.
58
59           This method automatically calls "consume".
60
61       "root_identifier"
62           Returns the blank node or URI for the root element of the Atom
63           document as an RDF::Trine::Node
64
65           Calls "consume" automatically.
66
67       "set_callbacks(\%callbacks)"
68           Set callback functions for the parser to call on certain events.
69           These are only necessary if you want to do something especially
70           unusual.
71
72             $p->set_callbacks({
73               'pretriple_resource' => sub { ... } ,
74               'pretriple_literal'  => sub { ... } ,
75               'ontriple'           => undef ,
76               });
77
78           For details of the callback functions, see the section CALLBACKS.
79           "set_callbacks" must be used before "consume". "set_callbacks"
80           itself returns a reference to the parser object itself.
81
82       "consume"
83           The document is parsed. Triples extracted from the document are
84           passed to the callbacks as each one is found; triples are made
85           available in the model returned by the "graph" method.
86
87           This function returns the parser object itself, making it easy to
88           abbreviate several of XML::Atom::OWL's functions:
89
90             my $iterator = XML::Atom::OWL->new(undef, $uri)
91                            ->consume->graph->as_stream;
92
93           You probably only need to call this explicitly if you're using
94           callbacks.
95

CALLBACKS

97       Several callback functions are provided. These may be set using the
98       "set_callbacks" function, which taskes a hashref of keys pointing to
99       coderefs. The keys are named for the event to fire the callback on.
100
101   pretriple_resource
102       This is called when a triple has been found, but before preparing the
103       triple for adding to the model. It is only called for triples with a
104       non-literal object value.
105
106       The parameters passed to the callback function are:
107
108       •   A reference to the "XML::Atom::OWL" object
109
110       •   A reference to the "XML::LibXML::Element" being parsed
111
112       •   Subject URI or bnode (string)
113
114       •   Predicate URI (string)
115
116       •   Object URI or bnode (string)
117
118       •   Graph URI or bnode (string or undef)
119
120       The callback should return 1 to tell the parser to skip this triple
121       (not add it to the graph); return 0 otherwise.
122
123   pretriple_literal
124       This is the equivalent of pretriple_resource, but is only called for
125       triples with a literal object value.
126
127       The parameters passed to the callback function are:
128
129       •   A reference to the "XML::Atom::OWL" object
130
131       •   A reference to the "XML::LibXML::Element" being parsed
132
133       •   Subject URI or bnode (string)
134
135       •   Predicate URI (string)
136
137       •   Object literal (string)
138
139       •   Datatype URI (string or undef)
140
141       •   Language (string or undef)
142
143       •   Graph URI or bnode (string or undef)
144
145       Beware: sometimes both a datatype and a language will be passed.  This
146       goes beyond the normal RDF data model.)
147
148       The callback should return 1 to tell the parser to skip this triple
149       (not add it to the graph); return 0 otherwise.
150
151   ontriple
152       This is called once a triple is ready to be added to the graph. (After
153       the pretriple callbacks.) The parameters passed to the callback
154       function are:
155
156       •   A reference to the "XML::Atom::OWL" object
157
158       •   A reference to the "XML::LibXML::Element" being parsed
159
160       •   An RDF::Trine::Statement object.
161
162       The callback should return 1 to tell the parser to skip this triple
163       (not add it to the graph); return 0 otherwise. The callback may modify
164       the RDF::Trine::Statement object.
165

BUGS

167       Please report any bugs to <http://rt.cpan.org/>.
168

SEE ALSO

170       RDF::Trine, XML::Atom::FromOWL.
171
172       <http://www.perlrdf.org/>.
173

AUTHOR

175       Toby Inkster <tobyink@cpan.org>.
176
178       Copyright 2010-2011 Toby Inkster
179
180       This library is free software; you can redistribute it and/or modify it
181       under the same terms as Perl itself.
182

DISCLAIMER OF WARRANTIES

184       THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
185       WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
186       MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
187
188
189
190perl v5.36.0                      2022-07-22                 XML::Atom::OWL(3)
Impressum